]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainIothreadMappingDefParse: Fix usage of virXMLNodeGetSubelementList
authorPeter Krempa <pkrempa@redhat.com>
Tue, 25 Feb 2025 11:42:49 +0000 (12:42 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 12 Mar 2025 11:56:58 +0000 (12:56 +0100)
virXMLNodeGetSubelementList always returns a non-NULL pointers thus we
should check the length instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c

index d5558738485c0ee0fee0c68d88383b9e9189af81..b94cf99236d21bc97f44c1a5239bb27ace32368d 100644 (file)
@@ -7970,19 +7970,21 @@ virDomainIothreadMappingDefParse(xmlNodePtr driverNode,
     if (!(iothreadsNode = virXMLNodeGetSubelement(driverNode, "iothreads")))
         return 0;
 
-    if (!(iothreadNodes = virXMLNodeGetSubelementList(iothreadsNode, "iothread")))
+    iothreadNodes = virXMLNodeGetSubelementList(iothreadsNode, "iothread");
+
+    if (iothreadNodes->len == 0)
         return 0;
 
     for (i = 0; i < iothreadNodes->len; i++) {
         xmlNodePtr iothNode = g_ptr_array_index(iothreadNodes, i);
         g_autoptr(virDomainIothreadMappingDef) iothdef = g_new0(virDomainIothreadMappingDef, 1);
-        g_autoptr(GPtrArray) queueNodes = NULL;
+        g_autoptr(GPtrArray) queueNodes = virXMLNodeGetSubelementList(iothNode, "queue");
 
         if (virXMLPropUInt(iothNode, "id", 10, VIR_XML_PROP_REQUIRED,
                            &iothdef->id) < 0)
             return -1;
 
-        if ((queueNodes = virXMLNodeGetSubelementList(iothNode, "queue"))) {
+        if (queueNodes->len > 0) {
             size_t q;
 
             iothdef->queues = g_new0(unsigned int, queueNodes->len);