File libxml2-CVE-2010-4494.patch of Package libxml2.import5659

Index: libxml2-2.7.8/xpath.c
===================================================================
--- libxml2-2.7.8.orig/xpath.c
+++ libxml2-2.7.8/xpath.c
@@ -11763,11 +11763,16 @@ xmlXPathCompOpEvalPositionalPredicate(xm
 
 	    if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
 	        xmlXPathObjectPtr tmp;
-		/* pop the result */
+		/* pop the result if any */
 		tmp = valuePop(ctxt);
+                if (tmp != contextObj) {
+                    /*
+                     * Free up the result
+                     * then pop off contextObj, which will be freed later
+                     */
 		xmlXPathReleaseObject(xpctxt, tmp);
-		/* then pop off contextObj, which will be freed later */
 		valuePop(ctxt);
+                }
 		goto evaluation_error;
 	    }
 
openSUSE Build Service is sponsored by