]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lxc_container: Don't dereference NULL upon failure
authorJim Meyering <meyering@redhat.com>
Thu, 5 Feb 2009 15:28:19 +0000 (15:28 +0000)
committerJim Meyering <meyering@redhat.com>
Thu, 5 Feb 2009 15:28:19 +0000 (15:28 +0000)
* src/lxc_container.c (lxcContainerPivotRoot): Free and zero
oldroot *after* printing the diagnostic, both for virFileMakePath
and pivot_root failure.

ChangeLog
src/lxc_container.c

index 26d254ffc9ab4c18c74d5ddfaef08fdfd7a6c13a..207854eab528ef4f216f6d1301451f5b5145b36f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Wed Feb 4 22:22:34 +0100 2009 Jim Meyering <meyering@redhat.com>
+
+       lxc_container: Don't dereference NULL upon failure
+       * src/lxc_container.c (lxcContainerPivotRoot): Free and zero
+       oldroot *after* printing the diagnostic, both for virFileMakePath
+       and pivot_root failure.
+
 Tue Feb  3 14:06:06 +0100 2009 Jim Meyering <meyering@redhat.com>
 
        avoid a format-related warning
index ea52eed93e3d02955a3197c2ddb050403b463b11..90c70d5367685361f748e86412ab6df90fa76706 100644 (file)
@@ -284,20 +284,20 @@ static int lxcContainerPivotRoot(virDomainFSDefPtr root)
     }
 
     if ((rc = virFileMakePath(oldroot)) < 0) {
-        VIR_FREE(oldroot);
         virReportSystemError(NULL, rc,
                              _("failed to create %s"),
                              oldroot);
+        VIR_FREE(oldroot);
         return -1;
     }
 
     /* The old root directory will live at /.oldroot after
      * this and will soon be unmounted completely */
     if (pivot_root(root->src, oldroot) < 0) {
-        VIR_FREE(oldroot);
         virReportSystemError(NULL, errno,
                              _("failed to pivot root %s to %s"),
                              oldroot, root->src);
+        VIR_FREE(oldroot);
         return -1;
     }
     VIR_FREE(oldroot);
@@ -677,4 +677,3 @@ int lxcContainerAvailable(int features)
 
     return 0;
 }
-