Skip to content

Commit fe165e7

Browse files
committed
coredump: flush accumulating buffer after parsing core file
1 parent 0e62d03 commit fe165e7

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/coredump/stacktrace.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ static int parse_core(int fd, const char *executable, char **ret, JsonVariant **
326326
.package_metadata = &package_metadata,
327327
.modules = &modules,
328328
};
329-
char *buf = NULL;
329+
_cleanup_free_ char *buf = NULL;
330330
size_t sz = 0;
331331
int r;
332332

@@ -379,6 +379,9 @@ static int parse_core(int fd, const char *executable, char **ret, JsonVariant **
379379
goto finish;
380380
}
381381

382+
r = fflush_and_check(c.f);
383+
if (r < 0)
384+
goto finish;
382385
c.f = safe_fclose(c.f);
383386

384387
*ret = TAKE_PTR(buf);
@@ -396,8 +399,6 @@ static int parse_core(int fd, const char *executable, char **ret, JsonVariant **
396399

397400
safe_fclose(c.f);
398401

399-
free(buf);
400-
401402
return r;
402403
}
403404

0 commit comments

Comments
 (0)