]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: fix memory leak related to stat_error_class
authorMasatake YAMATO <yamato@redhat.com>
Sat, 29 Nov 2025 19:10:46 +0000 (04:10 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Tue, 9 Dec 2025 21:21:42 +0000 (06:21 +0900)
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>
(cherry picked from commit 3ce751c0347de472ac1dcdd58e06a21759f1ad78)

lsfd-cmd/file.c

index 5ea3ccc572d4f86f3926d91b90b3d5709753a4ad..fbdadc4796e10942b5dccb89b3143555722b6176 100644 (file)
@@ -322,10 +322,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,
 };
 
 /*