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 d141fe0ffb57800095704fee6b0e37dede6f7e5e..80723c47f06c5c7635cf3a55515f68dd32dab4b9 100644 (file)
@@ -283,7 +283,11 @@ int journal_directory_vacuum(
 
                 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;