From cc38da00ef98f270e263dfe3188b2035f9b27c8a Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?=
Date: Sat, 8 Nov 2025 10:32:14 +0000 Subject: [PATCH] chcon: fix memory leak in error path * src/chcon.c (change_file_context): If compute_context_from_mask fails, free the previously allocated file_context. Fixes https://bugs.gnu.org/79780 --- src/chcon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/chcon.c b/src/chcon.c index f118820ccd..5f13c7d757 100644 --- a/src/chcon.c +++ b/src/chcon.c @@ -168,7 +168,10 @@ change_file_context (int fd, char const *file) } if (compute_context_from_mask (file_context, &context)) - return 1; + { + freecon (file_context); + return 1; + } context_string = context_str (context); } -- 2.47.3