[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Free alloc'ed memory on error path in matchpathcon_filespec_add
This patch fixes a trivial bug found in matchpathcon.c by Coverity:
When matchpathcon_filespec_add() fails to allocate fl->file
and jumps to oom:, it fails to free fl which was malloced
immedately above. Jump to oom_freefl: instead and free it.
Index: src/matchpathcon.c
===================================================================
--- src.orig/matchpathcon.c
+++ src/matchpathcon.c
@@ -274,11 +274,13 @@ int matchpathcon_filespec_add(ino_t ino,
fl->specind = specind;
fl->file = malloc(strlen(file) + 1);
if (!fl->file)
- goto oom;
+ goto oom_freefl;
strcpy(fl->file, file);
fl->next = prevfl->next;
prevfl->next = fl;
return fl->specind;
+oom_freefl:
+ free(fl);
oom:
myprintf("%s: insufficient memory for file label entry for %s\n",
__FUNCTION__, file);
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@xxxxxxxxxxxxx with
the words "unsubscribe selinux" without quotes as the message.
This mailing list archive is a service of Copilot Consulting.