libselinux/backport-libselinux-free-memory-in-error-branch.patch

39 lines
1.1 KiB
Diff
Raw Normal View History

2022-10-09 14:33:09 +08:00
From 8266fd9401b920bd3552410ebe215069891c373f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Tue, 10 May 2022 19:45:51 +0200
Subject: [PATCH] libselinux: free memory in error branch
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
In case the allocation for the filename fails, free the memory of the context.
Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
Acked-by: James Carter <jwcart2@gmail.com>
---
src/selinux_restorecon.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/selinux_restorecon.c b/src/selinux_restorecon.c
index 12b85101..c8db26c2 100644
--- a/src/selinux_restorecon.c
+++ b/src/selinux_restorecon.c
@@ -487,11 +487,13 @@ static int filespec_add(ino_t ino, const char *con, const char *file,
goto oom_freefl;
fl->file = strdup(file);
if (!fl->file)
- goto oom_freefl;
+ goto oom_freeflcon;
fl->next = prevfl->next;
prevfl->next = fl;
return 0;
+oom_freeflcon:
+ free(fl->con);
oom_freefl:
free(fl);
oom:
--
2.27.0