]> xenbits.xensource.com Git - libvirt.git/commitdiff
xen: Check return value of virStringReplace
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 23 Feb 2016 08:34:49 +0000 (09:34 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 23 Feb 2016 14:46:19 +0000 (15:46 +0100)
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 <mprivozn@redhat.com>
src/xenconfig/xen_xl.c

index 585ef9b8fcc106ec9c6888650b8f3ed4bc693fcf..98a7fa6a26e7b8265c8611b9a7d503897b0a1ef3 100644 (file)
@@ -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;