A patch for libXpm.a

Kate Feng feng1 at bnl.gov
Tue Aug 3 10:21:23 PDT 2010


To whom it may concern,

On Thursday, July 22, 2010, I sent a patch for libXpm.a to the list
http://www.aps.anl.gov/epics/tech-talk/2010/msg00965.php
Later on, xorg_info at x.org directed me to send the patch to this
list.

Please cc to me for any reply about this thread if  xorg_info at x.org is
a list server because I did not subscribe it.  The related code is
xpm-3.4k.tar.gz, which was downloaded from ftp://ftp.x.org/contrib/libraries.
The patch is attached below as well. It fixes the memory leak on all the Linux
machine (i.e. Debian, Ubutu, and RedHat).  If XpmReturnAllocPixels
is not specified in the attributes->valuemask, then
(*freeColors)() should be called.  I hope this helps.


Cheers,
Kate


diff -u create.c.orig create.c

--- create.c.orig 1998-03-19 14:51:00.000000000 -0500

+++ create.c 2010-05-20 09:42:41.000000000 -0400

@@ -929,8 +929,11 @@

if (attributes && (attributes->valuemask & XpmReturnAllocPixels)) {

attributes->alloc_pixels = alloc_pixels;

attributes->nalloc_pixels = nalloc_pixels;

- } else

- XpmFree(alloc_pixels);

+ } else {

+ /* Kate Feng: feeColors() if alloc'ed pixels is not return. Otherwise, 
memory leaks */

+ (*freeColors)(display, colormap, alloc_pixels, nalloc_pixels, NULL);

+ XpmFree(alloc_pixels);

+ }



/* return created images */

if (image_return)

@@ -2234,8 +2237,11 @@

if (attributes && (attributes->valuemask & XpmReturnAllocPixels)) {

attributes->alloc_pixels = alloc_pixels;

attributes->nalloc_pixels = nalloc_pixels;

- } else

- XpmFree(alloc_pixels);

+ } else {

+ /* Kate Feng: feeColors() if alloc'ed pixels is not return. Otherwise, 
memory leaks */

+ (*freeColors)(display, colormap, alloc_pixels, nalloc_pixels, NULL);

+ XpmFree(alloc_pixels);

+ }



   /* return created images */



   if (image_return)





------------------------------------------------------------------------







More information about the xorg mailing list