Another memory leak (gif coder)
Michal Kowalczuk <[email protected]> Tue, 13 Sep 2005 12:43:43 +0200
| Newsgroups | gmane.comp.video.graphicsmagick.bugs |
|---|---|
| Message-ID | <[email protected]> |
Here is a patch, that fixes memleak in gif coder (diff to gm-1.1.6).
Could you check if everything is ok?
#v+
--- GraphicsMagick/coders/gif.c 2005/08/12 14:59:14
+++ GraphicsMagick/coders/gif.c 2005/09/08 16:57:29
@@ -888,9 +888,11 @@
GIF Extension block.
*/
count=ReadBlob(image,1,(char *) &c);
- if (count == 0)
- ThrowReaderException(CorruptImageError,UnableToReadExtensionBlock,
+ if (count == 0) {
+ MagickFreeMemory(global_colormap);
+ ThrowReaderException(CorruptImageError,UnableToReadExtensionBlock,
image);
+ }
switch (c)
{
case 0xf9:
@@ -994,13 +996,17 @@
delay=0;
dispose=0;
iterations=1;
- if ((image->columns == 0) || (image->rows == 0))
+ if ((image->columns == 0) || (image->rows == 0)) {
+ MagickFreeMemory(global_colormap);
ThrowReaderException(CorruptImageError,NegativeOrZeroImageSize,image);
+ }
/*
Inititialize colormap.
*/
- if (!AllocateImageColormap(image,image->colors))
+ if (!AllocateImageColormap(image,image->colors)) {
+ MagickFreeMemory(global_colormap);
ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
+ }
if (!BitSet(flag,0x80))
{
/*
@@ -1048,8 +1054,10 @@
Decode image.
*/
status=DecodeImage(image,opacity);
- if (!image_info->ping && (status == False))
+ if (!image_info->ping && (status == False)) {
+ MagickFreeMemory(global_colormap);
ThrowReaderException(CorruptImageError,CorruptImage,image);
+ }
if (image_info->subrange != 0)
if (image->scene >= (image_info->subimage+image_info->subrange-1))
break;
#v-
--
_ <= MichaĆ Kowalczuk => <== (http://)|(mailto:sammael@)brzydal.eu.org/? ==>
( ` <= GG#2113900 => <======= Software is like sex: =========================>
\ /||\ /||\ /||\ |~~| <========== it's better when it's free.==============>
,_)/~|| ` || ` ||~\|~_|_ <============================= --Linus Torvalds ==>
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf