virsh: prevent potential NULL dereference

virXPathString() can return NULL so we need to use STRNEQ_NULLABLE here

Found by Linux Verification Center (linuxtesting.org) with Svace.

Reported-by: Dmitry Fedin <d.fedin@fobos-nt.ru>
Signed-off-by: Alexander Kuznetsov <kuznetsovam@altlinux.org>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Alexander Kuznetsov
2025-04-15 12:54:54 +02:00
committed by Michal Privoznik
parent 6230eed02c
commit 9ccd9676a8
+1 -1
View File
@@ -891,7 +891,7 @@ virshDomainConsoleCompleter(vshControl *ctl,
ctxt->node = parallels[i - nserials];
type = virXPathString("string(./@type)", ctxt);
if (STRNEQ(type, "pty"))
if (STRNEQ_NULLABLE(type, "pty"))
continue;
tmp[offset++] = virXPathString("string(./alias/@name)", ctxt);