From b805ff66d43c9fb526fec50bd90db61d735b7caf Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 10 Feb 2021 18:39:11 +0100 Subject: [PATCH] qemuMigrationSrcPerformPeer2Peer3: Don't leak 'dom_xml' on cleanup Use g_autofree for 'dom_xml' to free it on some of the (unlikely) code paths jumping to cleanup prior to the deallocation which is done right after it's not needed any more since it's a big string. Noticed when running under valgrind: ==2204780== 8,192 bytes in 1 blocks are definitely lost in loss record 2,539 of 2,551 ==2204780== at 0x483BCE8: realloc (vg_replace_malloc.c:834) ==2204780== by 0x4D890DF: g_realloc (in /usr/lib64/libglib-2.0.so.0.6600.4) ==2204780== by 0x4DA3AF0: g_string_append_vprintf (in /usr/lib64/libglib-2.0.so.0.6600.4) ==2204780== by 0x4917293: virBufferAsprintf (virbuffer.c:307) ==2204780== by 0x49B0B75: virDomainChrDefFormat (domain_conf.c:26109) ==2204780== by 0x49E25EF: virDomainDefFormatInternalSetRootName (domain_conf.c:28956) ==2204780== by 0x15F81D24: qemuDomainDefFormatBufInternal (qemu_domain.c:6204) ==2204780== by 0x15F8270D: qemuDomainDefFormatXMLInternal (qemu_domain.c:6229) ==2204780== by 0x15F8270D: qemuDomainDefFormatLive (qemu_domain.c:6279) ==2204780== by 0x15FD8100: qemuMigrationSrcBeginPhase (qemu_migration.c:2395) ==2204780== by 0x15FE0F0D: qemuMigrationSrcPerformPeer2Peer3 (qemu_migration.c:4640) ==2204780== by 0x15FE0F0D: qemuMigrationSrcPerformPeer2Peer (qemu_migration.c:5093) ==2204780== by 0x15FE0F0D: qemuMigrationSrcPerformJob (qemu_migration.c:5168) ==2204780== by 0x15FE280E: qemuMigrationSrcPerform (qemu_migration.c:5372) ==2204780== by 0x15F9BA3D: qemuDomainMigratePerform3Params (qemu_driver.c:11841) Signed-off-by: Peter Krempa Reviewed-by: Jiri Denemark --- src/qemu/qemu_migration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index f4826707c5..e8e35c1c7c 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -4345,7 +4345,7 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriverPtr driver, char *uri_out = NULL; char *cookiein = NULL; char *cookieout = NULL; - char *dom_xml = NULL; + g_autofree char *dom_xml = NULL; int cookieinlen = 0; int cookieoutlen = 0; int ret = -1;