From: Pádraig Brady Date: Sat, 8 Nov 2025 10:32:14 +0000 (+0000) Subject: chcon: fix memory leak in error path X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=HEAD;p=thirdparty%2Fcoreutils.git 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 --- 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); }