]> 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>
Sat, 29 Nov 2025 19:19:11 +0000 (04:19 +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>
lsfd-cmd/file.c

index 0df0554f578868579bcda3189d4082a6ae3ae2cb..d52f3a319469d977d1492228563cd8b40a34fb7e 100644 (file)
@@ -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,
 };
 
 /*