[PATCH] Only free memory for three levels of taxonomy

Rick Walsh rickmwalsh at gmail.com
Mon Jul 13 14:21:36 PDT 2015


On 13 July 2015 at 22:49, Dirk Hohndel <dirk at hohndel.org> wrote:

> On Mon, Jul 13, 2015 at 10:40:53PM +1000, Rick Walsh wrote:
> > We only use three levels of taxonomy, but we were attempting to free
> memory
> > for seven.  This led to some fun invalid point crashes.
> >
> > Please check I'm not way off the mark, but it definitely appears to fix
> the
> > crashes I was getting.
>
> I'm surprised this fixes your crashes.
> We actually store as many levels as we get back from the service - we just
> SHOW only three levels. And the other pointers SHOULD be NULL and
> therefore freeing them should be no problem.
>
> So I think your patch is wrong in that it will leak memory.


I hoped the cause was as simple as I thought, but a leaky fix to hide a
problem isn't all that helpful.


> But since we
> are already tracking how many entries we have, we might as well use that
> to limit how many pointers we free. I'll make a similar commit in a moment
> and would like you to test if that fixes your problem as well.
>
> Thanks for working on tracking this down.
>
> I just tried the latest master, including your fix.  I have bridge
foundations to design so haven't taken the time to understand how it works,
and how that differs from before, but I can say that it appears to have
fixed the problem. I.e. I can use the up/down arrows to scroll through my
entire dive list, whereas previously it would semi-reliably crash after ~20
dives.

Thanks,

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20150714/abbc8c2c/attachment.html>


More information about the subsurface mailing list