Blob Blame History Raw
From 8a44f62f8d1858ebab7f2bbb890d5f3eb2d2b316 Mon Sep 17 00:00:00 2001
Message-Id: <8a44f62f8d1858ebab7f2bbb890d5f3eb2d2b316.1377873641.git.jdenemar@redhat.com>
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
Date: Wed, 28 Aug 2013 10:24:13 +0200
Subject: [PATCH] virsh: free messages after logging them to a file

https://bugzilla.redhat.com/show_bug.cgi?id=1001957

The messages were only freed on error.

==12== 1,100 bytes in 1 blocks are definitely lost in loss record 698 of 729
==12==    by 0x4E98C22: virBufferAsprintf (virbuffer.c:294)
==12==    by 0x12C950: vshOutputLogFile (virsh.c:2440)
==12==    by 0x12880B: vshError (virsh.c:2254)
==12==    by 0x131957: vshCommandOptDomainBy (virsh-domain.c:109)
==12==    by 0x14253E: cmdStart (virsh-domain.c:3333)

https://bugzilla.redhat.com/show_bug.cgi?id=1001536
(cherry picked from commit 66d124b45472addc10d286ca291aa5411fcb381f)
---
 tools/virsh.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/virsh.c b/tools/virsh.c
index 34f5c4a..d1ae183 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2479,6 +2479,7 @@ vshOutputLogFile(vshControl *ctl, int log_level, const char *msg_format,
     if (safewrite(ctl->log_fd, str, len) < 0)
         goto error;
 
+    VIR_FREE(str);
     return;
 
 error:
-- 
1.8.3.2