]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: fix NULL check in virNetDevBandwidthParse
authorJán Tomko <jtomko@redhat.com>
Thu, 29 Nov 2012 09:37:53 +0000 (10:37 +0100)
committerEric Blake <eblake@redhat.com>
Thu, 29 Nov 2012 17:10:08 +0000 (10:10 -0700)
Found by coverity:
Error: REVERSE_INULL (CWE-476):
    libvirt-0.10.2/src/conf/netdev_bandwidth_conf.c:99: deref_ptr:
    Directly dereferencing pointer "node".
    libvirt-0.10.2/src/conf/netdev_bandwidth_conf.c:107:
    check_after_deref: Null-checking "node" suggests that it may be
    null, but it has already been dereferenced on all paths leading to
    the check.

src/conf/netdev_bandwidth_conf.c

index 261718f3ef6cd09ba8fb12872db06ed2651bc1d8..5802eba1225d7db671b4474ffd297e7efb25acb3 100644 (file)
@@ -96,7 +96,7 @@ virNetDevBandwidthPtr
 virNetDevBandwidthParse(xmlNodePtr node)
 {
     virNetDevBandwidthPtr def = NULL;
-    xmlNodePtr cur = node->children;
+    xmlNodePtr cur;
     xmlNodePtr in = NULL, out = NULL;
 
     if (VIR_ALLOC(def) < 0) {
@@ -110,6 +110,8 @@ virNetDevBandwidthParse(xmlNodePtr node)
         goto error;
     }
 
+    cur = node->children;
+
     while (cur) {
         if (cur->type == XML_ELEMENT_NODE) {
             if (xmlStrEqual(cur->name, BAD_CAST "inbound")) {