Memory leak in gif.c?

Glenn Randers-Pehrson <[email protected]> Mon, 15 Nov 2004 11:47:20 -0500
Newsgroups gmane.comp.video.graphicsmagick.bugs
Message-ID <[email protected]>
It looks as though the following code from gif.c (line 497) ought to free
packet, hash_code, hash_prefix, and hash_suffix when it detects
an Alloc failure in one of them.

  packet=MagickAllocateMemory(unsigned char *,256);
  hash_code=MagickAllocateMemory(short *,MaxHashTable*sizeof(short));
  hash_prefix=MagickAllocateMemory(short *,MaxHashTable*sizeof(short));
  hash_suffix=MagickAllocateMemory(unsigned char *,MaxHashTable);
  if ((packet == (unsigned char *) NULL) || (hash_code == (short *) NULL) ||
      (hash_prefix == (short *) NULL) ||
      (hash_suffix == (unsigned char *) NULL))
    return(MagickFail);

Similar problem at line 1240:

  global_colormap=MagickAllocateMemory(unsigned char *,768);
  colormap=MagickAllocateMemory(unsigned char *,768);
  if ((global_colormap == (unsigned char *) NULL) ||
      (colormap == (unsigned char *) NULL))
    ThrowWriterException(ResourceLimitError,MemoryAllocationFailed,image);

I have not run any tests to see if leakage actually occurs.

Glenn



-------------------------------------------------------
This SF.Net email is sponsored by: InterSystems CACHE
FREE OODBMS DOWNLOAD - A multidimensional database that combines
robust object and relational technologies, making it a perfect match
for Java, C++,COM, XML, ODBC and JDBC. www.intersystems.com/match8