? xcursor-memleak.patch Index: cursor.c =================================================================== RCS file: /cvs/xlibs/Xcursor/cursor.c,v retrieving revision 1.8 diff -u -p -r1.8 cursor.c --- cursor.c 17 Jun 2005 23:44:00 -0000 1.8 +++ cursor.c 21 Sep 2005 11:38:24 -0000 @@ -54,6 +54,7 @@ XcursorCursorsDestroy (XcursorCursors *c for (n = 0; n < cursors->ncursor; n++) XFreeCursor (cursors->dpy, cursors->cursors[n]); free (cursors); + cursors = NULL; } XcursorAnimate * @@ -75,6 +76,7 @@ XcursorAnimateDestroy (XcursorAnimate *a { XcursorCursorsDestroy (animate->cursors); free (animate); + animate = NULL; } Cursor Index: display.c =================================================================== RCS file: /cvs/xlibs/Xcursor/display.c,v retrieving revision 1.9 diff -u -p -r1.9 display.c --- display.c 12 Sep 2005 16:43:46 -0000 1.9 +++ display.c 21 Sep 2005 11:38:24 -0000 @@ -32,12 +32,19 @@ static void _XcursorFreeDisplayInfo (XcursorDisplayInfo *info) { if (info->theme) + { free (info->theme); + info->theme = NULL; + } if (info->theme_from_config) + { free (info->theme_from_config); + info->theme_from_config = NULL; + } free (info); + info = NULL; } static int Index: file.c =================================================================== RCS file: /cvs/xlibs/Xcursor/file.c,v retrieving revision 1.7 diff -u -p -r1.7 file.c --- file.c 29 Jun 2005 18:39:04 -0000 1.7 +++ file.c 21 Sep 2005 11:38:24 -0000 @@ -48,7 +48,10 @@ void XcursorImageDestroy (XcursorImage *image) { if (image) + { free (image); + image = NULL; + } } XcursorImages * @@ -77,8 +80,12 @@ XcursorImagesDestroy (XcursorImages *ima for (n = 0; n < images->nimage; n++) XcursorImageDestroy (images->images[n]); if (images->name) + { free (images->name); + images->name = NULL; + } free (images); + images = NULL; } void @@ -121,8 +128,11 @@ XcursorCommentCreate (XcursorUInt commen void XcursorCommentDestroy (XcursorComment *comment) { - if (!comment) - free (comment); + if (comment) + { + free (comment); + comment = NULL; + } } XcursorComments * @@ -150,6 +160,7 @@ XcursorCommentsDestroy (XcursorComments for (n = 0; n < comments->ncomment; n++) XcursorCommentDestroy (comments->comments[n]); free (comments); + comments = NULL; } static XcursorBool @@ -205,8 +216,11 @@ _XcursorWriteBytes (XcursorFile *file, c static void _XcursorFileHeaderDestroy (XcursorFileHeader *fileHeader) { - if (!fileHeader) - free (fileHeader); + if (fileHeader) + { + free (fileHeader); + fileHeader = NULL; + } } static XcursorFileHeader * @@ -634,11 +648,15 @@ XcursorXcFileLoadImage (XcursorFile *fil if (!fileHeader) return 0; bestSize = _XcursorFindBestSize (fileHeader, (XcursorDim) size, &nsize); - if (!bestSize) + if (!bestSize) { + _XcursorFileHeaderDestroy (fileHeader); return 0; + } toc = _XcursorFindImageToc (fileHeader, bestSize, 0); - if (toc < 0) + if (toc < 0) { + _XcursorFileHeaderDestroy (fileHeader); return 0; + } image = _XcursorReadImage (file, fileHeader, toc); _XcursorFileHeaderDestroy (fileHeader); return image; @@ -660,11 +678,15 @@ XcursorXcFileLoadImages (XcursorFile *fi if (!fileHeader) return 0; bestSize = _XcursorFindBestSize (fileHeader, (XcursorDim) size, &nsize); - if (!bestSize) + if (!bestSize) { + _XcursorFileHeaderDestroy (fileHeader); return 0; + } images = XcursorImagesCreate (nsize); - if (!images) + if (!images) { + _XcursorFileHeaderDestroy (fileHeader); return 0; + } for (n = 0; n < nsize; n++) { toc = _XcursorFindImageToc (fileHeader, bestSize, n); Index: library.c =================================================================== RCS file: /cvs/xlibs/Xcursor/library.c,v retrieving revision 1.8 diff -u -p -r1.8 library.c --- library.c 29 Jun 2005 18:39:04 -0000 1.8 +++ library.c 21 Sep 2005 11:38:24 -0000 @@ -317,14 +317,17 @@ XcursorLibraryLoadImages (const char *fi Cursor XcursorLibraryLoadCursor (Display *dpy, const char *file) { - int size = XcursorGetDefaultSize (dpy); - char *theme = XcursorGetTheme (dpy); - XcursorImages *images = XcursorLibraryLoadImages (file, theme, size); + int size; + char *theme; + XcursorImages *images; Cursor cursor; if (!file) return 0; + size = XcursorGetDefaultSize (dpy); + theme = XcursorGetTheme (dpy); + images = XcursorLibraryLoadImages (file, theme, size); if (!images) { int id = XcursorLibraryShape (file); @@ -345,14 +348,17 @@ XcursorLibraryLoadCursor (Display *dpy, XcursorCursors * XcursorLibraryLoadCursors (Display *dpy, const char *file) { - int size = XcursorGetDefaultSize (dpy); - char *theme = XcursorGetTheme (dpy); - XcursorImages *images = XcursorLibraryLoadImages (file, theme, size); + int size; + char *theme; + XcursorImages *images; XcursorCursors *cursors; if (!file) return NULL; + size = XcursorGetDefaultSize (dpy); + theme = XcursorGetTheme (dpy); + images = XcursorLibraryLoadImages (file, theme, size); if (!images) { int id = XcursorLibraryShape (file);