mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
vbox: check getenv("DISPLAY") for NULL in vboxDomainDumpXML
Otherwise this will segfault if DISPLAY is not defined.
This commit is contained in:
parent
fc1da688c0
commit
1443cbe840
@ -1915,6 +1915,7 @@ static char *vboxDomainDumpXML(virDomainPtr dom, int flags) {
|
|||||||
vboxIID *iid = NULL;
|
vboxIID *iid = NULL;
|
||||||
int gotAllABoutDef = -1;
|
int gotAllABoutDef = -1;
|
||||||
nsresult rc;
|
nsresult rc;
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
#if VBOX_API_VERSION == 2002
|
#if VBOX_API_VERSION == 2002
|
||||||
if (VIR_ALLOC(iid) < 0) {
|
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)) {
|
} else if ((vrdpPresent != 1) && (totalPresent == 0) && (VIR_ALLOC_N(def->graphics, 1) >= 0)) {
|
||||||
if (VIR_ALLOC(def->graphics[def->ngraphics]) >= 0) {
|
if (VIR_ALLOC(def->graphics[def->ngraphics]) >= 0) {
|
||||||
def->graphics[def->ngraphics]->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
|
def->graphics[def->ngraphics]->type = VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP;
|
||||||
def->graphics[def->ngraphics]->data.desktop.display = strdup(getenv("DISPLAY"));
|
tmp = getenv("DISPLAY");
|
||||||
if (def->graphics[def->ngraphics]->data.desktop.display == NULL) {
|
if (tmp != NULL) {
|
||||||
virReportOOMError();
|
def->graphics[def->ngraphics]->data.desktop.display = strdup(tmp);
|
||||||
/* just don't go to cleanup yet as it is ok to have
|
if (def->graphics[def->ngraphics]->data.desktop.display == NULL) {
|
||||||
* display as NULL
|
virReportOOMError();
|
||||||
*/
|
/* just don't go to cleanup yet as it is ok to have
|
||||||
|
* display as NULL
|
||||||
|
*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
totalPresent++;
|
totalPresent++;
|
||||||
def->ngraphics++;
|
def->ngraphics++;
|
||||||
|
Loading…
Reference in New Issue
Block a user