]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
conf: Fix mistakes in pointer usage in virDomainObjGetDefs
authorPeter Krempa <pkrempa@redhat.com>
Thu, 4 Jun 2015 11:20:12 +0000 (13:20 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 4 Jun 2015 12:03:38 +0000 (14:03 +0200)
Coverity rightfully determined that in commit 3d021381c71221e563182f03
I made a mistake in the first check if @persDef is not NULL is
dereferencing it rather than checking.

Additionally if the vm is online the code would set @liveDef twice
rather than modifying @persDef. Fix both mistakes.

src/conf/domain_conf.c

index 77e198cc22aaff9f9d2766d238f95b67f3a5f4ec..36de8441990eff0a8b2705e0bb4ebcbacc5cc4f8 100644 (file)
@@ -2927,7 +2927,7 @@ virDomainObjGetDefs(virDomainObjPtr vm,
     if (liveDef)
         *liveDef = NULL;
 
-    if (*persDef)
+    if (persDef)
         *persDef = NULL;
 
     if (virDomainObjUpdateModificationImpact(vm, &flags) < 0)
@@ -2938,7 +2938,7 @@ virDomainObjGetDefs(virDomainObjPtr vm,
             *liveDef = vm->def;
 
         if (persDef)
-            *liveDef = vm->newDef;
+            *persDef = vm->newDef;
     } else {
         if (persDef)
             *persDef = vm->def;