# HG changeset patch
# User William M. Brack <wbrack@src.gnome.org>
# Date 1096042516 0
#      Fri Sep 24 16:15:16 2004 +0000
# Node ID a9b03c3c2cb01a580a2f5ce0fdff38f09aa23d7a
# Parent  2aa9e64fe9e2a88c656b38d069419292e0b77c73
fixed problem with empty sets, etc. (see discussion on mailing list)

* libexslt/date.c: fixed problem with empty sets, etc.
  (see discussion on mailing list)

diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Sep 24 09:17:22 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+	* libexslt/date.c: fixed problem with empty sets, etc.
+	  (see discussion on mailing list)
+
 Sat Sep 18 17:08:31 PDT 2004 William Brack <wbrack@mmm.com.hk>
 
 	* libexslt/date.c: fixed problem with timezone offset
diff --git a/libexslt/date.c b/libexslt/date.c
--- a/libexslt/date.c
+++ b/libexslt/date.c
@@ -2748,20 +2748,28 @@
     if (xmlXPathCheckError (ctxt))
 	return;
 
-    if ((ns == NULL) || (ns->nodeNr == 0))
+    if ((ns == NULL) || (ns->nodeNr == 0)) {
+	xmlXPathReturnEmptyString (ctxt);
 	return;
+    }
 
     total = exsltDateCreateDate (XS_DURATION);
+    if (total == NULL)
+        return;
 
     for (i = 0; i < ns->nodeNr; i++) {
 
 	tmp = xmlXPathCastNodeToString (ns->nodeTab[i]);
-	if (tmp == NULL)
+	if (tmp == NULL) {
+	    exsltDateFreeDate (total);
 	    return;
+	}
 
 	x = exsltDateParseDuration (tmp);
 	if (x == NULL) {
 	    xmlFree (tmp);
+	    exsltDateFreeDate (total);
+	    xmlXPathReturnEmptyString (ctxt);
 	    return;
 	}