summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-10-08 10:48:25 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-10-08 10:48:25 -0700
commit5e0f8347cebef2b3a9f5d75ca254aabaa0bca259 (patch)
treeebb30bc06c5ee1c0ad60b243cf2d083da2b2a1dc
parent9c1b50ed98d354488329c99bc8bf77d1c6df657c (diff)
XcursorXcFileLoad: plug memory leak in error paths
Found by gcc analyzer: file.c: In function ‘XcursorXcFileLoad’: file.c:782:8: warning: leak of ‘fileHeader’ [CWE-401] [-Wanalyzer-malloc-leak] 782 | if (!images) | ^ Fixes: 3b84b14 ("Initial revision") Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/file.c b/src/file.c
index 0e26955..496d447 100644
--- a/src/file.c
+++ b/src/file.c
@@ -780,10 +780,14 @@ XcursorXcFileLoad (XcursorFile *file,
}
images = XcursorImagesCreate (nimage);
if (!images)
+ {
+ _XcursorFileHeaderDestroy (fileHeader);
return 0;
+ }
comments = XcursorCommentsCreate (ncomment);
if (!comments)
{
+ _XcursorFileHeaderDestroy (fileHeader);
XcursorImagesDestroy (images);
return 0;
}