]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredump: flush accumulating buffer after parsing core file
authorLuca Boccassi <luca.boccassi@microsoft.com>
Mon, 29 Nov 2021 10:23:49 +0000 (10:23 +0000)
committerLuca Boccassi <luca.boccassi@microsoft.com>
Tue, 30 Nov 2021 16:49:58 +0000 (16:49 +0000)
src/coredump/stacktrace.c

index 24ea087d382e8f787e397b242c64e068083d5d32..a74ef41ac9dc16785b385514b9ee2cdb2aa2a39a 100644 (file)
@@ -326,7 +326,7 @@ static int parse_core(int fd, const char *executable, char **ret, JsonVariant **
                 .package_metadata = &package_metadata,
                 .modules = &modules,
         };
-        char *buf = NULL;
+        _cleanup_free_ char *buf = NULL;
         size_t sz = 0;
         int r;
 
@@ -379,6 +379,9 @@ static int parse_core(int fd, const char *executable, char **ret, JsonVariant **
                 goto finish;
         }
 
+        r = fflush_and_check(c.f);
+        if (r < 0)
+                goto finish;
         c.f = safe_fclose(c.f);
 
         *ret = TAKE_PTR(buf);
@@ -396,8 +399,6 @@ finish:
 
         safe_fclose(c.f);
 
-        free(buf);
-
         return r;
 }