Re: Memory leak in attribute.c

Bob Friesenhahn <[email protected]> Wed, 4 Jan 2006 13:51:42 -0600 (CST)
Newsgroups gmane.comp.video.graphicsmagick.bugs
Message-ID <[email protected]>
On Wed, 4 Jan 2006, [iso-8859-2] Micha³ Kowalczuk wrote:

> Hi,
> I found a memory leak in magick/attribute.c, in function
> GenerateEXIFAttribute(). There is an allocation of a string:
> final=AllocateString("");
> but when function returns with False it is never freed.
> Here's a quick fix for that problem (the patch is for yesterday snapshot):

Thanks for the report.  The fix is almost as gross as the code.  Maybe 
a better approach is to use a 'goto' statement.  Certainly 'goto' is 
frowned on, but in this case it seems to make sense.  There is also 
the possiblity of adding an error-reporting macro which also releases 
any resources.  But I like the goto.

Bob
======================================
Bob Friesenhahn
[email protected], http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/