[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [libvirt-glib 1/3] Fix NULL deref when an attribute cannot be found



When gvir_config_xml_get_attribute_content fails to find the
attribute that the caller is looking for, we will try to dereference
'attr' which is NULL in this case. This will cause a crash.
---
 libvirt-gconfig/libvirt-gconfig-helpers.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-helpers.c b/libvirt-gconfig/libvirt-gconfig-helpers.c
index 49c7f90..3790cab 100644
--- a/libvirt-gconfig/libvirt-gconfig-helpers.c
+++ b/libvirt-gconfig/libvirt-gconfig-helpers.c
@@ -254,10 +254,10 @@ gvir_config_xml_get_attribute_content(xmlNodePtr node, const char *attr_name)
             continue;
 
         if (strcmp (attr_name, (char *)attr->name) == 0)
-            break;
+            return attr->children->content;
     }
 
-    return attr->children->content;
+    return NULL;
 }
 
 G_GNUC_INTERNAL const char *
-- 
1.7.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]