]> xenbits.xensource.com Git - libvirt.git/commitdiff
vbox: check getenv("DISPLAY") for NULL in vboxDomainDumpXML
authorMatthias Bolte <matthias.bolte@googlemail.com>
Thu, 10 Jun 2010 20:11:39 +0000 (22:11 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Thu, 10 Jun 2010 20:39:49 +0000 (22:39 +0200)
Otherwise this will segfault if DISPLAY is not defined.

src/vbox/vbox_tmpl.c

index 1372f963840cd97ce56bb9022abca9bf0670bdf4..dfa76a67050aca0f1222c0ef995cba5d4da82b8c 100644 (file)
@@ -1915,6 +1915,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
     vboxIID  *iid        = NULL;
     int gotAllABoutDef   = -1;
     nsresult rc;
+    char *tmp;
 
 #if VBOX_API_VERSION == 2002
     if (VIR_ALLOC(iid) < 0) {
@@ -2191,12 +2192,15 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
                 } else if ((vrdpPresent != 1) && (totalPresent == 0) && (VIR_ALLOC_N(def->graphics, 1) >= 0)) {
                     if (VIR_ALLOC(def->graphics[def->ngraphics]) >= 0) {
                         def->graphics[def->ngraphics]->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
-                        def->graphics[def->ngraphics]->data.desktop.display = strdup(getenv("DISPLAY"));
-                        if (def->graphics[def->ngraphics]->data.desktop.display == NULL) {
-                            virReportOOMError();
-                            /* just don't go to cleanup yet as it is ok to have
-                             * display as NULL
-                             */
+                        tmp = getenv("DISPLAY");
+                        if (tmp != NULL) {
+                            def->graphics[def->ngraphics]->data.desktop.display = strdup(tmp);
+                            if (def->graphics[def->ngraphics]->data.desktop.display == NULL) {
+                                virReportOOMError();
+                                /* just don't go to cleanup yet as it is ok to have
+                                 * display as NULL
+                                 */
+                            }
                         }
                         totalPresent++;
                         def->ngraphics++;