[libvirt-php][PATCH 2/5] src: Don't leak @uuid in libvirt_nwfilter_get_uuid_string

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

 



VIRT_RETURN_STRING() does immediate return. Therefore,
efree(uuid) is never called and thus leaked. Moreover, there's no
reason for dynamically allocated uuid buffer (in contrast to our
misuse of large static buffers).

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/libvirt-nwfilter.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/libvirt-nwfilter.c b/src/libvirt-nwfilter.c
index cd082a5..1b5dbdc 100644
--- a/src/libvirt-nwfilter.c
+++ b/src/libvirt-nwfilter.c
@@ -145,12 +145,11 @@ PHP_FUNCTION(libvirt_nwfilter_get_uuid_string)
 {
     php_libvirt_nwfilter *nwfilter = NULL;
     zval *znwfilter;
-    char *uuid = NULL;
+    char uuid[VIR_UUID_STRING_BUFLEN];
     int ret = -1;
 
     GET_NWFILTER_FROM_ARGS("r", &znwfilter);
 
-    uuid = (char *) emalloc(VIR_UUID_STRING_BUFLEN);
     ret = virNWFilterGetUUIDString(nwfilter->nwfilter, uuid);
 
     DPRINTF("%s: virNWFilterGetUUIDString(%p) returned %d (%s)\n", PHPFUNC,
@@ -160,7 +159,6 @@ PHP_FUNCTION(libvirt_nwfilter_get_uuid_string)
         RETURN_FALSE;
 
     VIRT_RETURN_STRING(uuid);
-    efree(uuid);
 }
 
 /*
-- 
2.13.6

--
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]
  Powered by Linux