aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasatake YAMATO <yamato@redhat.com>2025-11-30 04:10:46 +0900
committerMasatake YAMATO <yamato@redhat.com>2025-11-30 04:19:11 +0900
commit3ce751c0347de472ac1dcdd58e06a21759f1ad78 (patch)
treed084ba50838802a761e03ab132dd55341c3871f7
parentcc1f2ac99b99eede36a58cf115a56bdfbc977e52 (diff)
downloadutil-linux-3ce751c0347de472ac1dcdd58e06a21759f1ad78.tar.gz
lsfd: fix memory leak related to stat_error_class
Memory objects pointed by the name member of a file object allocate as an instance of stat_error_class are leaked. I intrdouced this bug in a125e2eea7cea4d0bac1404c2e1b1d65d11cc10c. In the commit, I arranged the class hierarchy. Signed-off-by: Masatake YAMATO <yamato@redhat.com>
-rw-r--r--lsfd-cmd/file.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lsfd-cmd/file.c b/lsfd-cmd/file.c
index 0df0554f57..d52f3a3194 100644
--- a/lsfd-cmd/file.c
+++ b/lsfd-cmd/file.c
@@ -319,10 +319,16 @@ const struct file_class readlink_error_class = {
.fill_column = readlink_error_fill_column,
};
+static void stat_error_file_free_content(struct file *file)
+{
+ free(file->name);
+}
+
const struct file_class stat_error_class = {
.super = &error_class,
.size = sizeof(struct file),
.initialize_content = init_error_content,
+ .free_content = stat_error_file_free_content,
};
/*