Fix setting of the dive_table.preexisting logic

Linus Torvalds torvalds at linux-foundation.org
Wed Jan 23 13:19:58 PST 2013


The 'preexisting' value is used for downloading dives: we want to add
new dives but, but then compare those new dives against the
preexisting ones before we start sorting things and possibly merging
them.

However, the value was only updated sporadically, resulting in it
having stale information in it.  Which would cause problems
particularly if you deleted dives, so that the preexisting value would
point past the actual existing values!

So just update it unconditionally in dive_list_update_dives(), which
anything that changes the dive list is supposed to call in order to
display the changes anyway.

Also, just for safety, when removing a dive, put NULL in the last dive
table location.  Nobody should ever access past the end anyway (this
is enforced by 'get_dive()') but there are places that access the dive
list table directly, and the libdivecomputer download was one of
those.  No reason to leave stale dive pointers possibly around for
uses like that.

Reported-by: Henrik Brautaset Aronsen <subsurface at henrik.synth.no>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---

This is the bug Henrik found.

        Linus

On Wed, Jan 23, 2013 at 12:59 PM, Linus Torvalds
<torvalds at linux-foundation.org> wrote:
> On Wed, Jan 23, 2013 at 12:31 PM, Henrik Brautaset Aronsen
> <subsurface at henrik.synth.no> wrote:
>>
>> I tried, but Valgrind doesn't work properly in MacOSX 10.8 yet:
>
> I can reproduce it, although not entirely reliably. I'll fix it,
>
>             Linus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-setting-of-the-dive_table.preexisting-logic.patch
Type: application/octet-stream
Size: 3145 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130123/83c561ed/attachment-0001.obj>


More information about the subsurface mailing list