[Libvir] [PATCH] Fix some memory leaks in xs_internal.c

Masayuki Sunou fj1826dm at aa.jp.fujitsu.com
Fri Aug 17 07:21:19 UTC 2007


Hi

Some memory releases is missed in xs_internal.c.
This patch fixes it.

Signed-off-by: Masayuki Sunou <fj1826dm at aa.jp.fujitsu.com>

Thanks,
Masayuki Sunou.

----------------------------------------------------------------------
Index: src/xs_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xs_internal.c,v
retrieving revision 1.47
diff -u -p -r1.47 xs_internal.c
--- src/xs_internal.c	10 Aug 2007 18:25:15 -0000	1.47
+++ src/xs_internal.c	17 Aug 2007 05:19:00 -0000
@@ -578,6 +578,8 @@ xenStoreListDomains(virConnectPtr conn, 
 #endif
 	ids[ret++] = (int) id;
     }
+    if (idlist)
+        free(idlist);
     return(ret);
 }
 
@@ -637,11 +639,10 @@ xenStoreLookupByName(virConnectPtr conn,
     path = xs_get_domain_path(priv->xshandle, (unsigned int) id);
 
     if (!found)
-        return(NULL);
+        goto done;
 
     ret = virGetDomain(conn, name, NULL);
     if (ret == NULL) {
-        if (path != NULL) free(path);
         goto done;
     }
     ret->id = id;
@@ -651,6 +652,8 @@ done:
 	free(xenddomain);
     if (idlist != NULL)
 	free(idlist);
+    if (path != NULL)
+        free(path);
 
     return(ret);
 }
----------------------------------------------------------------------




More information about the libvir-list mailing list