From: John Ferlan Date: Wed, 13 May 2015 10:24:50 +0000 (-0400) Subject: storage: Resolve Coverity FORWARD_NULL X-Git-Tag: v1.2.16-rc1~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2d0243f4d6333ec7be8726bf905cec88f9b9d90c;p=thirdparty%2Flibvirt.git storage: Resolve Coverity FORWARD_NULL Coverity points out it's possible for one of the virCommand{Output|Error}* API's to have not allocated 'output' and/or 'error' in which case the strstr comparison will cause a NULL deref Signed-off-by: John Ferlan --- diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index 6394dac255..4dc63d753e 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -413,8 +413,8 @@ virStorageBackendDiskFindLabel(const char* device) /* if parted succeeds we have a valid partition table */ ret = virCommandRun(cmd, NULL); if (ret < 0) { - if (strstr(output, "unrecognised disk label") || - strstr(error, "unrecognised disk label")) { + if ((output && strstr(output, "unrecognised disk label")) || + (error && strstr(error, "unrecognised disk label"))) { ret = 1; } }