Memory leak and a logical bug in coders/gif.c
"Alexander E. Patrakov" <[email protected]> Sun, 4 Jan 2009 21:20:56 +0500
| Newsgroups | gmane.comp.video.image-magick.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello.
In coders/gif.c (trunk), line 1140, memory is allocated for the gif
profile. Then it is resized, but never freed.
Also, handling of the "8bim" profile just below that is questionable.
Namely, the string "8bim" is copied to name just to be overwritten by
the generic fallback.
Patch for both issues is below.
--- coders/gif.c
+++ coders/gif.c
@@ -1153,15 +1153,15 @@
SetStringInfoDatum(profile,(const unsigned char *) info);
if (i8bim == MagickTrue)
(void) CopyMagickString(name,"8bim",sizeof(name));
- if (icc == MagickTrue)
+ else if (icc == MagickTrue)
(void) CopyMagickString(name,"icc",sizeof(name));
+ else if (iptc == MagickTrue)
+ (void) CopyMagickString(name,"iptc",sizeof(name));
else
- if (iptc == MagickTrue)
- (void) CopyMagickString(name,"iptc",sizeof(name));
- else
- (void) FormatMagickString(name,sizeof(name),"gif:%.11s",
+ (void) FormatMagickString(name,sizeof(name),"gif:%.11s",
header);
(void) SetImageProfile(image,name,profile);
+ info=RelinquishMagickMemory(info);
profile=DestroyStringInfo(profile);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" profile name=%s",name);
--
Alexander E. Patrakov