chiark / gitweb /
journald: fix memory leak on error path
authorLennart Poettering <lennart@poettering.net>
Mon, 3 Nov 2014 22:10:34 +0000 (23:10 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 3 Nov 2014 22:10:34 +0000 (23:10 +0100)
src/journal/journal-vacuum.c

index d141fe0..80723c4 100644 (file)
@@ -283,7 +283,11 @@ int journal_directory_vacuum(
 
                 patch_realtime(directory, p, &st, &realtime);
 
 
                 patch_realtime(directory, p, &st, &realtime);
 
-                GREEDY_REALLOC(list, n_allocated, n_list + 1);
+                if (!GREEDY_REALLOC(list, n_allocated, n_list + 1)) {
+                        free(p);
+                        r = -ENOMEM;
+                        goto finish;
+                }
 
                 list[n_list].filename = p;
                 list[n_list].usage = 512UL * (uint64_t) st.st_blocks;
 
                 list[n_list].filename = p;
                 list[n_list].usage = 512UL * (uint64_t) st.st_blocks;