[libvirt] [PATCH] qemumonitorjsontest: Don't leak 'query-jobs' info

Michal Privoznik posted 1 patch 4 years, 8 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/6a63bf17dad7f1b9cd93e663272563d4d71657a0.1564402994.git.mprivozn@redhat.com
tests/qemumonitorjsontest.c | 3 +++
1 file changed, 3 insertions(+)
[libvirt] [PATCH] qemumonitorjsontest: Don't leak 'query-jobs' info
Posted by Michal Privoznik 4 years, 8 months ago
The returned array of qemuMonitorJobInfo structs must be freed.

164 (16 direct, 148 indirect) bytes in 1 blocks are definitely lost in loss record 64 of 84
   at 0x4A3568B: realloc (vg_replace_malloc.c:826)
   by 0x4D888BD: virReallocN (viralloc.c:244)
   by 0x4D889B3: virExpandN (viralloc.c:293)
   by 0x4D88C87: virInsertElementsN (viralloc.c:435)
   by 0x214004: qemuMonitorJSONGetJobInfo (qemu_monitor_json.c:9185)
   by 0x148B3F: testQueryJobs (qemumonitorjsontest.c:2979)
   by 0x14C192: virTestRun (testutils.c:174)
   by 0x14BF36: mymain (qemumonitorjsontest.c:3286)
   by 0x14E256: virTestMain (testutils.c:1096)
   by 0x14BFD9: main (qemumonitorjsontest.c:3298)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tests/qemumonitorjsontest.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index bf89f49aca..522ff5a3d5 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2996,6 +2996,9 @@ testQueryJobs(const void *opaque)
     ret = 0;
 
  cleanup:
+    for (i = 0; i < njobs; i++)
+        qemuMonitorJobInfoFree(jobs[i]);
+    VIR_FREE(jobs);
     qemuMonitorTestFree(test);
     return ret;
 }
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemumonitorjsontest: Don't leak 'query-jobs' info
Posted by Peter Krempa 4 years, 8 months ago
On Mon, Jul 29, 2019 at 14:23:14 +0200, Michal Privoznik wrote:
> The returned array of qemuMonitorJobInfo structs must be freed.
> 
> 164 (16 direct, 148 indirect) bytes in 1 blocks are definitely lost in loss record 64 of 84
>    at 0x4A3568B: realloc (vg_replace_malloc.c:826)
>    by 0x4D888BD: virReallocN (viralloc.c:244)
>    by 0x4D889B3: virExpandN (viralloc.c:293)
>    by 0x4D88C87: virInsertElementsN (viralloc.c:435)
>    by 0x214004: qemuMonitorJSONGetJobInfo (qemu_monitor_json.c:9185)
>    by 0x148B3F: testQueryJobs (qemumonitorjsontest.c:2979)
>    by 0x14C192: virTestRun (testutils.c:174)
>    by 0x14BF36: mymain (qemumonitorjsontest.c:3286)
>    by 0x14E256: virTestMain (testutils.c:1096)
>    by 0x14BFD9: main (qemumonitorjsontest.c:3298)
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  tests/qemumonitorjsontest.c | 3 +++
>  1 file changed, 3 insertions(+)

ACK
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list