[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] qemu: plug memory leak



From: Alex Jia <ajia redhat com>

Deteted by valgrind:

==18462== 1,100 bytes in 1 blocks are definitely lost in loss record 183 of 184
==18462==    at 0x4A05FDE: malloc (vg_replace_malloc.c:236)
==18462==    by 0x4A06167: realloc (vg_replace_malloc.c:525)
==18462==    by 0x4AADBB: virReallocN (memory.c:161)
==18462==    by 0x4A975E: virBufferGrow (buf.c:117)
==18462==    by 0x4A9D92: virBufferVasprintf (buf.c:290)
==18462==    by 0x4A9EF7: virBufferAsprintf (buf.c:263)
==18462==    by 0x429488: qemuBuildControllerDevStr (qemu_command.c:1993)
==18462==    by 0x42C4B6: qemuBuildCommandLine (qemu_command.c:3803)
==18462==    by 0x41A604: testCompareXMLToArgvHelper (qemuxml2argvtest.c:124)
==18462==    by 0x41BB81: virtTestRun (testutils.c:141)
==18462==    by 0x416DFF: mymain (qemuxml2argvtest.c:369)
==18462==    by 0x41B277: virtTestMain (testutils.c:696)
==18462==
==18462== LEAK SUMMARY:
==18462==    definitely lost: 1,100 bytes in 1 blocks
==18462==    indirectly lost: 0 bytes in 0 blocks

* src/qemu/qemu_command.c (qemuBuildCommandLine): Clean up on success.

Signed-off-by: Alex Jia <ajia redhat com>
---
 src/qemu/qemu_command.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0c5bfab..9c435de 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3804,6 +3804,7 @@ qemuBuildCommandLine(virConnectPtr conn,
                         goto error;
 
                     virCommandAddArg(cmd, devstr);
+                    VIR_FREE(devstr);
                 }
             } else if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
                 def->controllers[i]->model == -1 &&
-- 
1.7.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]