From e0392f5a747dc771808086a3cc0f940b9287eaf5 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 23 Feb 2016 09:34:49 +0100 Subject: [PATCH] xen: Check return value of virStringReplace After 6604a3dd9f8 in which new helper function has been introduced, the code calls virStringReplace and dereference the result immediately. The string function can, however, return NULL so this would SIGSEGV right away. Check for the return value of the string function. Signed-off-by: Michal Privoznik --- src/xenconfig/xen_xl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 585ef9b8fc..98a7fa6a26 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -254,7 +254,8 @@ xenParseXLDiskSrc(virDomainDiskDefPtr disk, char *srcstr) int ret = -1; if (STRPREFIX(srcstr, "rbd:")) { - tmpstr = virStringReplace(srcstr, "\\\\", "\\"); + if (!(tmpstr = virStringReplace(srcstr, "\\\\", "\\"))) + goto cleanup; virDomainDiskSetType(disk, VIR_STORAGE_TYPE_NETWORK); disk->src->protocol = VIR_STORAGE_NET_PROTOCOL_RBD; -- GitLab