xmlCopyNode() may return NULL. Add a check and log an error
in this case.
Found by Linux Verification Center (linuxtesting.org) with Svace.
Fixes: 22766a1a53 ("virshFindDisk: Sanitize use of 'tmp' variable")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
STREQ_NULLABLE(sourceDir, path) ||
STREQ_NULLABLE(sourceName, path)) {
xmlNodePtr ret = xmlCopyNode(nodes[i], 1);
+ if (!ret) {
+ vshError(NULL, "%s", _("Failed to copy XML node"));
+ return NULL;
+ }
/* drop backing store since they are not needed here */
virshDiskDropBackingStore(ret);
return ret;