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

[libvirt] [libvirt-php] Fixed minor memory leak



---
 src/libvirt-php.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index b6a848f..7870fcf 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -222,8 +222,8 @@ PHP_MINFO_FUNCTION(libvirt)
 
 	if (virGetVersion(&libVer,NULL,NULL)== 0)
 	{
-		version=emalloc(100);
-		snprintf(version, 100, "%i.%i.%i", (long)((libVer/1000000) % 1000),(long)((libVer/1000) % 1000),(long)(libVer % 1000));
+		char version[100];
+		snprintf(version, sizeof(version), "%i.%i.%i", (long)((libVer/1000000) % 1000),(long)((libVer/1000) % 1000),(long)(libVer % 1000));
 		php_info_print_table_row(2, "Libvirt version", version);
 	}
 
@@ -3883,10 +3883,12 @@ PHP_FUNCTION(libvirt_list_active_domains)
 			if (name==NULL)
 			{
 				efree (ids);
+				virDomainFree (domain);
 				RETURN_FALSE;
 			}
 
 			add_next_index_string(return_value, name, 1);
+			virDomainFree (domain);
 		}
 	}
 	efree(ids);
-- 
1.7.3.4
v


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