[PATCH 1/2] Make 'clear_dive()' free the primary dive computer data properly

Linus Torvalds torvalds at linux-foundation.org
Thu Jun 9 16:53:40 PDT 2016


On Thu, Jun 9, 2016 at 4:19 PM, Rick Walsh <rickmwalsh at gmail.com> wrote:
>> From: Linus Torvalds <torvalds at linux-foundation.org>
>> Subject: [PATCH 1/2] Make 'clear_dive()' free the primary dive computer data properly
>
> This change leads to an invalid pointer error when cancelling a planned
> dive.

Hmm. Running under valgrind shows that MainWindow::setupForAddAndPlan() does a

     clear_dive(&displayed_dive);

and it 's the

     free((void *)dc->model);

in there that causes problems.

You have a slightly different thing, with the call sequence being
copy_dive -> clear_dive. But I suspect the causes are the same:
there's a "struct dive" that hasn't been fully initialized and has a
bogus dc->model in itr.

I'll try to see what I can get, but can you let me know exactly what
your sequence was? I tried opening an empty file, then plan a dive and
cancel it immediately. That didn't fail, but the *second* time I did
it I got the problem.

                Linus


More information about the subsurface mailing list