]> xenbits.xensource.com Git - libvirt.git/commitdiff
virLogHostnameString: Don't leak hostname
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 6 Jan 2016 16:07:06 +0000 (17:07 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 8 Jan 2016 08:16:33 +0000 (09:16 +0100)
Once @hostname is printed into @hoststr we don't need it anymore.

==6879== 5 bytes in 1 blocks are definitely lost in loss record 10 of 1,064
==6879==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==6879==    by 0xA7ED599: strdup (in /lib64/libc-2.21.so)
==6879==    by 0x552C126: virStrdup (virstring.c:726)
==6879==    by 0x553B13E: virGetHostnameImpl (virutil.c:720)
==6879==    by 0x553B1BF: virGetHostnameQuiet (virutil.c:741)
==6879==    by 0x54FA3FD: virLogHostnameString (virlog.c:462)
==6879==    by 0x54FAB0F: virLogVMessage (virlog.c:645)
==6879==    by 0x54FA680: virLogMessage (virlog.c:531)
==6879==    by 0x54FBBF4: virLogParseOutputs (virlog.c:1130)
==6879==    by 0x11CB4F: daemonSetupLogging (libvirtd.c:685)
==6879==    by 0x11E137: main (libvirtd.c:1297)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virlog.c

index 7d5a266dd4fdf335fd5f54611186375462942f31..ecb102405138a1c57b5a9a2f39fa55d244aaed41 100644 (file)
@@ -469,6 +469,7 @@ virLogHostnameString(const char **rawmsg,
         VIR_FREE(hostname);
         return -1;
     }
+    VIR_FREE(hostname);
 
     if (virLogFormatString(msg, 0, NULL, VIR_LOG_INFO, hoststr) < 0) {
         VIR_FREE(hoststr);