From: Stefano Stabellini Date: Fri, 11 Feb 2011 17:54:51 +0000 (+0000) Subject: qemu-xen: fix segfault with empty cdroms X-Git-Tag: xen-4.1.0-rc5^0 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=e073e69457b4d99b6da0b6536296e3498f7f6599;p=qemu-xen-4.1-testing.git qemu-xen: fix segfault with empty cdroms When the cdrom is empty the params node in xenstore might be missing completely. Cope with it instead of segfaulting. Signed-off-by: Stefano Stabellini --- diff --git a/hw/xen_disk.c b/hw/xen_disk.c index 218f65451..6aebb77ba 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -582,12 +582,13 @@ static int blk_init(struct XenDevice *xendev) { struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); int mode, qflags, have_barriers, info = 0; - char *h; + char *h = NULL; /* read xenstore entries */ if (blkdev->params == NULL) { blkdev->params = xenstore_read_be_str(&blkdev->xendev, "params"); - h = strchr(blkdev->params, ':'); + if (blkdev->params != NULL) + h = strchr(blkdev->params, ':'); if (h != NULL) { blkdev->fileproto = blkdev->params; blkdev->filename = h+1;