]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Fix crash on OOM in xenParseXM handling consoles
authorDaniel P. Berrange <berrange@redhat.com>
Tue, 24 Sep 2013 15:45:09 +0000 (16:45 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Wed, 25 Sep 2013 14:49:28 +0000 (15:49 +0100)
The xenParseXM sets def->nconsoles to 1 before claling
VIR_REALLOC_N on def->consoles. So if the alloc fails
due to OOM, the cleanup code will crash accessing a
console that does not exist.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/xenxs/xen_xm.c

index 4386fefa67a02721d138c8d95b8f78f7a20575dd..1652fff7982e99729318350cad48cb921f2ddb2e 100644 (file)
@@ -1112,9 +1112,9 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
             }
         }
     } else {
-        def->nconsoles = 1;
         if (VIR_ALLOC_N(def->consoles, 1) < 0)
             goto cleanup;
+        def->nconsoles = 1;
         if (!(def->consoles[0] = xenParseSxprChar("pty", NULL)))
             goto cleanup;
         def->consoles[0]->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE;