]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vshInit: Don't leak @histsize_env
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 3 Sep 2015 12:37:14 +0000 (14:37 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 3 Sep 2015 12:44:57 +0000 (14:44 +0200)
Caller is responsible for freeing the result of virStringJoin()
when no longer needed:

==10701== 1 bytes in 1 blocks are definitely lost in loss record 1 of 806
==10701==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==10701==    by 0xAADB679: strdup (in /lib64/libc-2.20.so)
==10701==    by 0x4F18655: virStrdup (virstring.c:726)
==10701==    by 0x4F175AF: virStringJoin (virstring.c:165)
==10701==    by 0x131D4D: vshReadlineInit (vsh.c:2572)
==10701==    by 0x1322DF: vshInit (vsh.c:2736)
==10701==    by 0x1347C1: main (virsh.c:907)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tools/vsh.c

index 1a5b6e8efecf9a0023a4d763793a4e7d6e59dfb6..54c4614a67814624b3d945c74ce40e140876d607 100644 (file)
@@ -2552,8 +2552,8 @@ vshReadlineInit(vshControl *ctl)
     char *name_capitalized = NULL;
     int max_history = 500;
     int ret = -1;
+    char *histsize_env = NULL;
     const char *histsize_str = NULL;
-    const char *histsize_env = NULL;
     const char *strings[] = {
         name_capitalized,
         "HISTSIZE",
@@ -2613,6 +2613,7 @@ vshReadlineInit(vshControl *ctl)
  cleanup:
     VIR_FREE(userdir);
     VIR_FREE(name_capitalized);
+    VIR_FREE(histsize_env);
     return ret;
 }