]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
test:///default driver: don't dereference NULL "def"
authorJim Meyering <meyering@redhat.com>
Fri, 13 Feb 2009 18:11:03 +0000 (18:11 +0000)
committerJim Meyering <meyering@redhat.com>
Fri, 13 Feb 2009 18:11:03 +0000 (18:11 +0000)
* src/test.c (testNetworkCreate, testNetworkDefine): Since "def" is
set to NULL immediately after any vir*AssignDef call (to indicate we
no longer own it and to ensure no clean-up path mistakenly frees it),
dereference via net->def->, not def->.

ChangeLog
src/test.c

index 9f84264519bba7e5fccf00ca2d2475803f60a572..38d5efa92d36c0a456d2bb9885ed23f4032756da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Feb 13 19:09:54 +0100 2009 Jim Meyering <meyering@redhat.com>
+
+       test:///default driver: don't dereference NULL "def"
+       * src/test.c (testNetworkCreate, testNetworkDefine): Since "def" is
+       set to NULL immediately after any vir*AssignDef call (to indicate we
+       no longer own it and to ensure no clean-up path mistakenly frees it),
+       dereference via net->def->, not def->.
+
 Fri Feb 13 12:31:03 CET 2009 Guido Günther <agx@sigxcpu.org>
 
        usleep to wait for domain logfile to fill up
index 0e0ec7c400b4cff4a6bb69b5921b353554b29c11..226fe2e91583558a13e60e0b1950d779c32d8590 100644 (file)
@@ -2049,14 +2049,12 @@ static virNetworkPtr testNetworkCreate(virConnectPtr conn, const char *xml) {
     if ((def = virNetworkDefParseString(conn, xml)) == NULL)
         goto cleanup;
 
-    if ((net = virNetworkAssignDef(conn, &privconn->networks,
-                                   def)) == NULL) {
+    if ((net = virNetworkAssignDef(conn, &privconn->networks, def)) == NULL)
         goto cleanup;
-    }
-    net->active = 1;
     def = NULL;
+    net->active = 1;
 
-    ret = virGetNetwork(conn, def->name, def->uuid);
+    ret = virGetNetwork(conn, net->def->name, net->def->uuid);
 
 cleanup:
     virNetworkDefFree(def);
@@ -2076,14 +2074,12 @@ static virNetworkPtr testNetworkDefine(virConnectPtr conn, const char *xml) {
     if ((def = virNetworkDefParseString(conn, xml)) == NULL)
         goto cleanup;
 
-    if ((net = virNetworkAssignDef(conn, &privconn->networks,
-                                   def)) == NULL) {
+    if ((net = virNetworkAssignDef(conn, &privconn->networks, def)) == NULL)
         goto cleanup;
-    }
-    net->persistent = 1;
     def = NULL;
+    net->persistent = 1;
 
-    ret = virGetNetwork(conn, def->name, def->uuid);
+    ret = virGetNetwork(conn, net->def->name, net->def->uuid);
 
 cleanup:
     virNetworkDefFree(def);
@@ -2529,9 +2525,8 @@ testStoragePoolCreate(virConnectPtr conn,
         goto cleanup;
     }
 
-    if (!(pool = virStoragePoolObjAssignDef(conn, &privconn->pools, def))) {
+    if (!(pool = virStoragePoolObjAssignDef(conn, &privconn->pools, def)))
         goto cleanup;
-    }
     def = NULL;
 
     if (testStoragePoolObjSetDefaults(conn, pool) == -1) {
@@ -2568,9 +2563,8 @@ testStoragePoolDefine(virConnectPtr conn,
     def->allocation = defaultPoolAlloc;
     def->available = defaultPoolCap - defaultPoolAlloc;
 
-    if (!(pool = virStoragePoolObjAssignDef(conn, &privconn->pools, def))) {
+    if (!(pool = virStoragePoolObjAssignDef(conn, &privconn->pools, def)))
         goto cleanup;
-    }
     def = NULL;
 
     if (testStoragePoolObjSetDefaults(conn, pool) == -1) {