[PATCH 1/4] test_driver: Don't leak @group_name

Michal Privoznik posted 4 patches 4 years ago
[PATCH 1/4] test_driver: Don't leak @group_name
Posted by Michal Privoznik 4 years ago
In testDomainSetBlockIoTune() the info.group_name is strdup()-ed
and just after the whole @info structure is passed to
virDomainDiskSetBlockIOTune() the @group_name member is set to
NULL. This creates a memleak, because
virDomainDiskSetBlockIOTune() creates its own copy of the string.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/test/test_driver.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 1504334c30..9e1fc65972 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -4027,7 +4027,6 @@ testDomainSetBlockIoTune(virDomainPtr dom,
 #undef TEST_BLOCK_IOTUNE_MAX_CHECK
 
     virDomainDiskSetBlockIOTune(conf_disk, &info);
-    info.group_name = NULL;
 
     ret = 0;
  cleanup:
-- 
2.34.1

Re: [PATCH 1/4] test_driver: Don't leak @group_name
Posted by Erik Skultety 4 years ago
On Mon, Jan 31, 2022 at 03:53:39PM +0100, Michal Privoznik wrote:
> In testDomainSetBlockIoTune() the info.group_name is strdup()-ed
> and just after the whole @info structure is passed to
> virDomainDiskSetBlockIOTune() the @group_name member is set to
> NULL. This creates a memleak, because
> virDomainDiskSetBlockIOTune() creates its own copy of the string.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
Reviewed-by: Erik Skultety <eskultet@redhat.com>