aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2025-11-08 10:32:14 +0000
committerPádraig Brady <P@draigBrady.com>2025-11-08 10:41:48 +0000
commitcc38da00ef98f270e263dfe3188b2035f9b27c8a (patch)
tree997546fdee96b9841556b5239187b67a41513365
parenttests: avoid false failure due to small timeout (diff)
downloadcoreutils-cc38da00ef98f270e263dfe3188b2035f9b27c8a.tar.gz
coreutils-cc38da00ef98f270e263dfe3188b2035f9b27c8a.zip
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
-rw-r--r--src/chcon.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/chcon.c b/src/chcon.c
index f118820cc..5f13c7d75 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);
}