Skip to content

Commit 1210415

Browse files
committed
journalctl: fix memleak
bash-4.3# journalctl --no-hostname >/dev/null ================================================================= ==288==ERROR: LeakSanitizer: detected memory leaks Direct leak of 48492 byte(s) in 2694 object(s) allocated from: #0 0x7fb4aba13e60 in malloc (/lib64/libasan.so.3+0xc6e60) systemd#1 0x7fb4ab5b2cc4 in malloc_multiply src/basic/alloc-util.h:70 systemd#2 0x7fb4ab5b3194 in parse_field src/shared/logs-show.c:98 systemd#3 0x7fb4ab5b4918 in output_short src/shared/logs-show.c:347 systemd#4 0x7fb4ab5b7cb7 in output_journal src/shared/logs-show.c:977 systemd#5 0x5650e29cd83d in main src/journal/journalctl.c:2581 systemd#6 0x7fb4aabdb730 in __libc_start_main (/lib64/libc.so.6+0x20730) SUMMARY: AddressSanitizer: 48492 byte(s) leaked in 2694 allocation(s). Closes: systemd#4568
1 parent 9156493 commit 1210415

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/shared/logs-show.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ static int output_short(
418418

419419
if (flags & OUTPUT_NO_HOSTNAME) {
420420
/* Suppress display of the hostname if this is requested. */
421-
hostname = NULL;
421+
hostname = mfree(hostname);
422422
hostname_len = 0;
423423
}
424424

0 commit comments

Comments
 (0)