]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: fix memleak 4578/head
authorEvgeny Vereshchagin <evvers@ya.ru>
Thu, 3 Nov 2016 21:23:22 +0000 (21:23 +0000)
committerEvgeny Vereshchagin <evvers@ya.ru>
Thu, 3 Nov 2016 21:23:22 +0000 (21:23 +0000)
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)
    #1 0x7fb4ab5b2cc4 in malloc_multiply src/basic/alloc-util.h:70
    #2 0x7fb4ab5b3194 in parse_field src/shared/logs-show.c:98
    #3 0x7fb4ab5b4918 in output_short src/shared/logs-show.c:347
    #4 0x7fb4ab5b7cb7 in output_journal src/shared/logs-show.c:977
    #5 0x5650e29cd83d in main src/journal/journalctl.c:2581
    #6 0x7fb4aabdb730 in __libc_start_main (/lib64/libc.so.6+0x20730)

SUMMARY: AddressSanitizer: 48492 byte(s) leaked in 2694 allocation(s).

Closes: #4568
src/shared/logs-show.c

index f9d9c4ed62a088d8e8653cf711308d81202ea670..5ad5ade31e5ff7a18b92154ecc3096fb6c9c3aa7 100644 (file)
@@ -418,7 +418,7 @@ static int output_short(
 
         if (flags & OUTPUT_NO_HOSTNAME) {
                 /* Suppress display of the hostname if this is requested. */
-                hostname = NULL;
+                hostname = mfree(hostname);
                 hostname_len = 0;
         }