[PATCH v3] Fixed NULL pointer check

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

 



This patch fixes a NULL pointer check that was causing SegFault on
some specific configurations. It also reverts commit 59d0c9801c1ab
that was checking for this value in one place.
---
v3:
 - added revert of 59d0c9801c1ab that's not needed anymore

 - (comment) ATTRIBUTE_RETURN_CHECK not added as it is not used with other
   functions defined in this file and the commit could be confusing modifying
   all of them together. However, there should be one patch to fix all these
   at once if possible

v2:
 - removed parenthesis around return value

 src/libvirt.c   |    3 +--
 src/util/conf.c |    5 ++++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 7f8d42c..99b263e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1085,8 +1085,7 @@ virConnectOpenResolveURIAlias(virConfPtr conf,

     *uri = NULL;

-    if (conf &&
-        (value = virConfGetValue(conf, "uri_aliases")))
+    if ((value = virConfGetValue(conf, "uri_aliases")))
         ret = virConnectOpenFindURIAliasMatch(value, alias, uri);
     else
         ret = 0;
diff --git a/src/util/conf.c b/src/util/conf.c
index 8ad60e0..3370337 100644
--- a/src/util/conf.c
+++ b/src/util/conf.c
@@ -1,7 +1,7 @@
 /**
  * conf.c: parser for a subset of the Python encoded Xen configuration files
  *
- * Copyright (C) 2006-2011 Red Hat, Inc.
+ * Copyright (C) 2006-2012 Red Hat, Inc.
  *
  * See COPYING.LIB for the License of this software
  *
@@ -836,6 +836,9 @@ virConfGetValue(virConfPtr conf, const char *setting)
 {
     virConfEntryPtr cur;

+    if (conf == NULL)
+        return NULL;
+
     cur = conf->entries;
     while (cur != NULL) {
         if ((cur->name != NULL) &&
--
1.7.3.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]