launch: Handle guestfs_config qemu_value == NULL.

The second parameter to 'config' may be NULL.

In commit 52fa23d74f (refactoring of
guestfs_config) the code this got lost, and guestfs_config would
segfault if qemu_value was NULL.

Also this fixes the libvirt method to handle the same case.

I checked libguestfs-1.18 and -1.16 branches, and this problem does
NOT affect them.
This commit is contained in:
Richard W.M. Jones
2012-09-21 12:42:53 +01:00
parent 763ec36cf0
commit 1b364d74a8
2 changed files with 8 additions and 6 deletions

View File

@@ -1103,11 +1103,13 @@ construct_libvirt_xml_qemu_cmdline (guestfs_h *g, xmlTextWriterPtr xo)
BAD_CAST qp->qemu_param));
XMLERROR (-1, xmlTextWriterEndElement (xo));
XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "qemu:arg"));
XMLERROR (-1,
xmlTextWriterWriteAttribute (xo, BAD_CAST "value",
BAD_CAST qp->qemu_value));
XMLERROR (-1, xmlTextWriterEndElement (xo));
if (qp->qemu_value) {
XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "qemu:arg"));
XMLERROR (-1,
xmlTextWriterWriteAttribute (xo, BAD_CAST "value",
BAD_CAST qp->qemu_value));
XMLERROR (-1, xmlTextWriterEndElement (xo));
}
}
XMLERROR (-1, xmlTextWriterEndElement (xo));

View File

@@ -320,7 +320,7 @@ guestfs__config (guestfs_h *g,
qp = safe_malloc (g, sizeof *qp);
qp->qemu_param = safe_strdup (g, qemu_param);
qp->qemu_value = safe_strdup (g, qemu_value);
qp->qemu_value = qemu_value ? safe_strdup (g, qemu_value) : NULL;
qp->next = g->qemu_params;
g->qemu_params = qp;