Possible memory leak in SDL 1.2.7

Hi there,

I’ve been using valgrind to look at the memory usage of my program, and it’s
warning me about quite a few instances of unfreed memory, mostly stemming
from the X11_CreateWMCursor function. For example:

---------- snip ----------
==9776== 8227 bytes in 414 blocks are still reachable in loss record 63 of 64
==9776== at 0x3C01D40D: malloc (vg_replace_malloc.c:105)
==9776== by 0x3C6CE961: PutEntry (in /usr/X11R6/lib/libX11.so.6.2)
==9776== by 0x3C6CF6D9: GetDatabase (in /usr/X11R6/lib/libX11.so.6.2)
==9776== by 0x3C6CB093: XrmGetStringDatabase
(in /usr/X11R6/lib/libX11.so.6.2)
==9776== by 0x3C6AFCC7: InitDefaults (in /usr/X11R6/lib/libX11.so.6.2)
==9776== by 0x3C6AF96D: XGetDefault (in /usr/X11R6/lib/libX11.so.6.2)
==9776== by 0x3C945242: _XcursorGetDisplayInfo
(in /usr/X11R6/lib/libXcursor.so.1.0)
==9776== by 0x3C9452DE: XcursorSupportsARGB
(in /usr/X11R6/lib/libXcursor.so.1.0)
==9776== by 0x3C9484EB: XcursorNoticeCreateBitmap
(in /usr/X11R6/lib/libXcursor.so.1.0)
==9776== by 0x3C6A9CC5: _XNoticeCreateBitmap
(in /usr/X11R6/lib/libX11.so.6.2)
==9776== by 0x3C6AA2AC: XCreatePixmap (in /usr/X11R6/lib/libX11.so.6.2)
==9776== by 0x3C57522D: X11_CreateWMCursor
(in /usr/lib/libSDL-1.2.so.0.0.6)
---------- snip ----------

Taking a look at this function X11_CreateWMCursor and its companion
X11_FreeWMCursor (in src/video/x11/SDL_x11mouse.c), I can see that
X11_CreateWMCursor is making several calls to XCreatePixmap, but there are no
corresponding calls in X11_FreeWMCursor to XFreePixmap.

Am I missing something here? I am by no means an X11 programming expert, but
this just doesn’t look right.

Cheers,
Paul

Taking a look at this function X11_CreateWMCursor and its companion
X11_FreeWMCursor (in src/video/x11/SDL_x11mouse.c), I can see that
X11_CreateWMCursor is making several calls to XCreatePixmap, but there are no
corresponding calls in X11_FreeWMCursor to XFreePixmap.

Wow, I can’t believe that went unnoticed for years. :slight_smile:

Thanks! This should be fixed in CVS.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment