]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
libxl_domain: Resolve Coverity RESOURCE_LEAK
authorJohn Ferlan <jferlan@redhat.com>
Wed, 27 Aug 2014 18:47:43 +0000 (14:47 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 28 Aug 2014 12:12:16 +0000 (08:12 -0400)
On the error path need to free the chrdef

src/libxl/libxl_domain.c

index cdac82cd031b7a721485933f167c148b090d732f..557fc20f9abf0a573d430f74d6cca9c28b8ae68d 100644 (file)
@@ -532,8 +532,10 @@ libxlDomainDefPostParse(virDomainDefPtr def,
         chrdef->target.port = 0;
         chrdef->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
 
-        if (VIR_ALLOC_N(def->consoles, 1) < 0)
+        if (VIR_ALLOC_N(def->consoles, 1) < 0) {
+            virDomainChrDefFree(chrdef);
             return -1;
+        }
 
         def->nconsoles = 1;
         def->consoles[0] = chrdef;