[libvirt-php][PATCH 3/3] Revisit some VIRT_RETURN_STRING

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

 



This macro sets return value and returns immediately. This can
lead to a possible leak because any free() that would come
afterwards is in fact never called.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/libvirt-php.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index fb0679b..6f6e137 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -4307,7 +4307,8 @@ PHP_FUNCTION(libvirt_domain_qemu_agent_command)
        ret = virDomainQemuAgentCommand(domain->domain, cmd, timeout, flags);
        if (ret == NULL) RETURN_FALSE;
 
-       VIRT_RETURN_STRING(ret);
+       VIRT_RETVAL_STRING(ret);
+       free(ret);
 }
 
 /*
@@ -6691,7 +6692,7 @@ PHP_FUNCTION(libvirt_domain_memory_peek)
     buff=(char *)emalloc(size);
     retval=virDomainMemoryPeek(domain->domain,start,size,buff,flags);
     if (retval != 0) RETURN_FALSE;
-    VIRT_RETURN_STRINGL(buff, size);
+    VIRT_RETVAL_STRINGL(buff, size);
     efree(buff);
 }
 
@@ -7872,7 +7873,8 @@ PHP_FUNCTION(libvirt_storagevolume_get_path)
     DPRINTF("%s: virStorageVolGetPath(%p) returned %s\n", PHPFUNC, volume->volume, retval);
     if (retval == NULL) RETURN_FALSE;
 
-    VIRT_RETURN_STRING(retval);
+    VIRT_RETVAL_STRING(retval);
+    free(retval);
 }
 
 /*
@@ -9506,7 +9508,8 @@ PHP_FUNCTION(libvirt_network_get_bridge)
         RETURN_FALSE;
     }
 
-    VIRT_RETURN_STRING(name);
+    VIRT_RETVAL_STRING(name);
+    free(name);
 }
 
 /*
-- 
2.7.3

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]