[Pkg-libvirt-commits] [libguestfs] 147/165: v2v: Avoid segfault if xpath expression doesn't match any nodes.

Hilko Bengen bengen at moszumanska.debian.org
Sat Aug 30 08:25:24 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit af31670d03b83df424cfa540cc6020cce1a8340d
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Thu Jun 19 13:28:22 2014 +0100

    v2v: Avoid segfault if xpath expression doesn't match any nodes.
    
    I'm not sure if this indicates that the xpath expression is wrong, but
    in any case it can be that xpathobj->nodesetval is NULL.  In this
    case, return 0 from xpathobj_nr_nodes instead of segfaulting.
---
 v2v/xml-c.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/v2v/xml-c.c b/v2v/xml-c.c
index a1b796c..cf5bff2 100644
--- a/v2v/xml-c.c
+++ b/v2v/xml-c.c
@@ -165,7 +165,10 @@ v2v_xml_xpathobj_nr_nodes (value xpathobjv)
   CAMLparam1 (xpathobjv);
   xmlXPathObjectPtr xpathobj = Xpathobj_val (xpathobjv);
 
-  CAMLreturn (Val_int (xpathobj->nodesetval->nodeNr));
+  if (xpathobj->nodesetval == NULL)
+    CAMLreturn (Val_int (0));
+  else
+    CAMLreturn (Val_int (xpathobj->nodesetval->nodeNr));
 }
 
 value

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list