fixed mlXPathCompOpEvalPositionalPredicate problem with object caching

* xpath.c: fixed mlXPathCompOpEvalPositionalPredicate problem
  with object caching (bug #469410)

svn path=/trunk/; revision=3653
diff --git a/ChangeLog b/ChangeLog
index d3d115f..060c053 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Aug 23 20:58:28 HKT 2007 William Brack <wbrack@mmm.com.hk>
+
+	* xpath.c: fixed mlXPathCompOpEvalPositionalPredicate problem
+	  with object caching (bug #469410)
+
 Thu Aug 23 11:28:38 CEST 2007 Daniel Veillard <daniel@veillard.com>
 
 	* xmlschemas.c test/schemas/*455953* result/schemas/bug455953*:
diff --git a/xpath.c b/xpath.c
index 9c4db87..22a3f9d 100644
--- a/xpath.c
+++ b/xpath.c
@@ -11706,8 +11706,15 @@
 	    valuePush(ctxt, contextObj);
 	    res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1);
 	    
-	    if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1))
+	    if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
+	        xmlXPathObjectPtr tmp;
+		/* pop the result */
+		tmp = valuePop(ctxt);
+		xmlXPathReleaseObject(xpctxt, tmp);
+		/* then pop off contextObj, which will be freed later */
+		valuePop(ctxt);
 		goto evaluation_error;
+	    }
 
 	    if (res)
 		pos++;