]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: Plug memory leak on error path
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 24 Sep 2024 19:30:13 +0000 (21:30 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Sat, 28 Sep 2024 04:09:13 +0000 (23:09 -0500)
Fix memory leak on error path introduced with read_u32 error checks.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/153
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-index.c

index 949a78391e27e94c34fd8fd471e60e60e7c6e97d..154cc43b77fce42987ad978ae73b06ef538a7436 100644 (file)
@@ -338,8 +338,10 @@ struct index_file *index_file_open(const char *filename)
                goto err;
 
        new->file = file;
-       if (read_u32(new->file, &new->root_offset) < 0)
+       if (read_u32(new->file, &new->root_offset) < 0) {
+               free(new);
                goto err;
+       }
 
        errno = 0;
        return new;