diff --git a/ChangeLog b/ChangeLog
index b0685a40d7a572c1a2aee166a1261089fc150b6a_Q2hhbmdlTG9n..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_Q2hhbmdlTG9n 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Fri Mar 10 12:49:18 CET 2006 Daniel Veillard <daniel@veillard.com>
+
+	* libexslt/crypto.c libexslt/date.c libexslt/saxon.c
+	  libxslt/attributes.c libxslt/imports.c libxslt/pattern.c
+	  libxslt/preproc.c libxslt/transform.c libxslt/variables.c
+	  libxslt/xslt.c libxslt/xsltutils.c: various assorted small cleanups
+	  based on the Coverity reports
+
 Wed Feb 22 16:09:10 CET 2006 Daniel Veillard <daniel@veillard.com>
 
 	* python/types.c: Nic Ferrier found debug statement left in the
diff --git a/NEWS b/NEWS
index b0685a40d7a572c1a2aee166a1261089fc150b6a_TkVXUw==..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_TkVXUw== 100644
--- a/NEWS
+++ b/NEWS
@@ -11,13 +11,12 @@
 http://cvs.gnome.org/viewcvs/libxslt/
  code base.Those are the public releases made:
 1.1.15: Sep 04 2005:
-   - build fixes: Windows build cleanups and updates (Igor Zlatkovic), remove
-      jhbuild warnings
-   - bug fixes: negative number formatting (William Brack), number formatting
-      per mille definition (William Brack), XInclude default values (William),
-      text copy bugs (William), bug related to xmlXPathContext size, reuse
-      libxml2 memory management for text nodes, dictionnary text bug, forbid
-      variables in match (needs libxml2-2.6.21)
-   - improvements: EXSLT dyn:map (Mark Vakoc), 
-  
+   - build fixes: Windows build cleanups and updates (Igor Zlatkovic),
+    remove jhbuild warnings
+   - bug fixes: negative number formatting (William Brack), number
+    formatting per mille definition (William Brack), XInclude default values
+    (William), text copy bugs (William), bug related to xmlXPathContext size,
+    reuse libxml2 memory management for text nodes, dictionnary text bug,
+    forbid variables in match (needs libxml2-2.6.21)
+   - improvements: EXSLT dyn:map (Mark Vakoc),
    - documentation: EXSLT date and time functions namespace in man (Jonathan
@@ -23,6 +22,6 @@
    - documentation: EXSLT date and time functions namespace in man (Jonathan
-      Wakely)
+    Wakely)
 
 
 1.1.14: Apr 02 2005:
    - bug fixes: text node on stylesheet document without a dictionary
@@ -25,10 +24,10 @@
 
 
 1.1.14: Apr 02 2005:
    - bug fixes: text node on stylesheet document without a dictionary
-      (William Brack), more checking of XSLT syntax, calling xsltInit() multiple
-      times, mode values interning raised by Mark Vakoc, bug in pattern
-      matching with ancestors, bug in patterna matching with cascading select,
-      xinclude and document() problem, build outside of source tree (Mike
-      Castle)
+    (William Brack), more checking of XSLT syntax, calling xsltInit()
+    multiple times, mode values interning raised by Mark Vakoc, bug in
+    pattern matching with ancestors, bug in patterna matching with cascading
+    select, xinclude and document() problem, build outside of source tree
+    (Mike Castle)
    - improvement: added a --nodict mode to xsltproc to check problems for
@@ -34,7 +33,6 @@
    - improvement: added a --nodict mode to xsltproc to check problems for
-      docuemtns without dictionnaries
-
+    docuemtns without dictionnaries
 
 
 1.1.13: Mar 13 2005:
    - build fixes: 64bits cleanup (William Brack), python 2.4 test (William),
@@ -37,8 +35,7 @@
 
 
 1.1.13: Mar 13 2005:
    - build fixes: 64bits cleanup (William Brack), python 2.4 test (William),
-      LIBXSLT_VERSION_EXTRA on Windows (William), Windows makefiles fixes
-      (Joel Reed), libgcrypt-devel requires for RPM spec.
-  
+    LIBXSLT_VERSION_EXTRA on Windows (William), Windows makefiles fixes (Joel
+    Reed), libgcrypt-devel requires for RPM spec.
    - bug fixes: exslt day-of-week-in-month (Sal Paradise), xsl:call-template
@@ -44,14 +41,12 @@
    - bug fixes: exslt day-of-week-in-month (Sal Paradise), xsl:call-template
-      should not change the current template rule (William Brack), evaluation
-      of global variables (William Brack), RVT's in XPath predicates (William),
-      namespace URI on template names (Mark Vakoc), stat() for Windows patch
-      (Aleksey Gurtovoy), pattern expression fixes (William Brack), out of
-      memory detection misses (William), parserOptions propagation (William),
-      exclude-result-prefixes fix (William), // patten fix (William).
-  
-   - extensions: module support (Joel Reed), dictionnary based speedups 
-      trying to get rid of xmlStrEqual as much as possible.
-  
+    should not change the current template rule (William Brack), evaluation
+    of global variables (William Brack), RVT's in XPath predicates (William),
+    namespace URI on template names (Mark Vakoc), stat() for Windows patch
+    (Aleksey Gurtovoy), pattern expression fixes (William Brack), out of
+    memory detection misses (William), parserOptions propagation (William),
+    exclude-result-prefixes fix (William), // patten fix (William).
+   - extensions: module support (Joel Reed), dictionnary based speedups
+    trying to get rid of xmlStrEqual as much as possible.
    - documentation: added Wiki (Joel Reed)
 
 
@@ -55,7 +50,6 @@
    - documentation: added Wiki (Joel Reed)
 
 
-
 1.1.12: Oct 29 2004:
    - build fixes: warnings removal (William).
    - bug fixes: attribute document pointer fix (Mark Vakoc), exslt date
diff --git a/libexslt/crypto.c b/libexslt/crypto.c
index b0685a40d7a572c1a2aee166a1261089fc150b6a_bGliZXhzbHQvY3J5cHRvLmM=..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_bGliZXhzbHQvY3J5cHRvLmM= 100644
--- a/libexslt/crypto.c
+++ b/libexslt/crypto.c
@@ -621,8 +621,12 @@
 /* encrypt it */
     bin_len = str_len;
     bin = xmlStrdup (str);
+    if (bin == NULL) {
+	xmlXPathReturnEmptyString (ctxt);
+	goto done;
+    }
     PLATFORM_RC4_ENCRYPT (ctxt, padkey, str, str_len, bin, bin_len);
 
 /* encode it */
     hex_len = str_len * 2 + 1;
     hex = xmlMallocAtomic (hex_len);
@@ -624,9 +628,13 @@
     PLATFORM_RC4_ENCRYPT (ctxt, padkey, str, str_len, bin, bin_len);
 
 /* encode it */
     hex_len = str_len * 2 + 1;
     hex = xmlMallocAtomic (hex_len);
+    if (hex == NULL) {
+	xmlXPathReturnEmptyString (ctxt);
+	goto done;
+    }
 
     exsltCryptoBin2Hex (bin, str_len, hex, hex_len);
     xmlXPathReturnString (ctxt, hex);
 
@@ -629,7 +637,8 @@
 
     exsltCryptoBin2Hex (bin, str_len, hex, hex_len);
     xmlXPathReturnString (ctxt, hex);
 
+done:
     if (key != NULL)
 	xmlFree (key);
     if (str != NULL)
diff --git a/libexslt/date.c b/libexslt/date.c
index b0685a40d7a572c1a2aee166a1261089fc150b6a_bGliZXhzbHQvZGF0ZS5j..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_bGliZXhzbHQvZGF0ZS5j 100644
--- a/libexslt/date.c
+++ b/libexslt/date.c
@@ -553,8 +553,8 @@
 static int
 _exsltDateParseTimeZone (exsltDateValDatePtr dt, const xmlChar **str)
 {
-    const xmlChar *cur = *str;
+    const xmlChar *cur;
     int ret = 0;
 
     if (str == NULL)
 	return -1;
@@ -557,8 +557,8 @@
     int ret = 0;
 
     if (str == NULL)
 	return -1;
-
+    cur = *str;
     switch (*cur) {
     case 0:
 	dt->tz_flag = 0;
@@ -1522,6 +1522,14 @@
             long tyr  = r->year + (long)FQUOTIENT_RANGE((int)r->mon-1, 1, 13);
             if (tyr == 0)
                 tyr--;
+	    /*
+	     * Coverity detected an overrun in daysInMonth 
+	     * of size 12 at position 12 with index variable "((r)->mon - 1)"
+	     */
+	    if (tmon < 0)
+	        tmon = 0;
+	    if (tmon > 12)
+	        tmon = 12;
             tempdays += MAX_DAYINMONTH(tyr, tmon);
             carry = -1;
         } else if (tempdays > (long)MAX_DAYINMONTH(r->year, r->mon)) {
diff --git a/libexslt/saxon.c b/libexslt/saxon.c
index b0685a40d7a572c1a2aee166a1261089fc150b6a_bGliZXhzbHQvc2F4b24uYw==..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_bGliZXhzbHQvc2F4b24uYw== 100644
--- a/libexslt/saxon.c
+++ b/libexslt/saxon.c
@@ -221,6 +221,7 @@
 	if ((nodelist == NULL) || (nodelist->nodeNr <= 0)) {
 	    xmlXPathFreeObject(obj);
 	    valuePush(ctxt, xmlXPathNewFloat(-1));
+	    return;
 	}
 	cur = nodelist->nodeTab[0];
 	for (i = 1;i < nodelist->nodeNr;i++) {
diff --git a/libxslt/attributes.c b/libxslt/attributes.c
index b0685a40d7a572c1a2aee166a1261089fc150b6a_bGlieHNsdC9hdHRyaWJ1dGVzLmM=..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_bGlieHNsdC9hdHRyaWJ1dGVzLmM= 100644
--- a/libxslt/attributes.c
+++ b/libxslt/attributes.c
@@ -578,10 +578,8 @@
     const xmlChar *URL = NULL;
 
 
-    if (ctxt->insert == NULL)
-        return;
-    if (comp == NULL) {
+    if ((comp == NULL) || (ctxt == NULL)) {
         xsltTransformError(ctxt, NULL, inst,
                          "xsl:attribute : compilation failed\n");
         return;
     }
@@ -584,5 +582,7 @@
         xsltTransformError(ctxt, NULL, inst,
                          "xsl:attribute : compilation failed\n");
         return;
     }
+    if (ctxt->insert == NULL)
+        return;
 
@@ -588,6 +588,5 @@
 
-    if ((ctxt == NULL) || (node == NULL) || (inst == NULL)
-        || (comp == NULL))
+    if ((node == NULL) || (inst == NULL) || (comp == NULL))
         return;
     if (!comp->has_name) {
         return;
diff --git a/libxslt/imports.c b/libxslt/imports.c
index b0685a40d7a572c1a2aee166a1261089fc150b6a_bGlieHNsdC9pbXBvcnRzLmM=..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_bGlieHNsdC9pbXBvcnRzLmM= 100644
--- a/libxslt/imports.c
+++ b/libxslt/imports.c
@@ -278,7 +278,7 @@
 	return(cur->next) ;
     do {
 	cur = cur->parent;
-	if (cur == NULL) return(NULL);
+	if (cur == NULL) break;
 	if (cur->next != NULL) return(cur->next);
     } while (cur != NULL);
     return(cur);
diff --git a/libxslt/pattern.c b/libxslt/pattern.c
index b0685a40d7a572c1a2aee166a1261089fc150b6a_bGlieHNsdC9wYXR0ZXJuLmM=..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_bGlieHNsdC9wYXR0ZXJuLmM= 100644
--- a/libxslt/pattern.c
+++ b/libxslt/pattern.c
@@ -740,8 +740,6 @@
 		    continue;
 		}
 		while (node != NULL) {
-		    if (node == NULL)
-			goto rollback;
 		    if ((node->type == XML_ELEMENT_NODE) &&
 			(step->value[0] == node->name[0]) &&
 			(xmlStrEqual(step->value, node->name))) {
diff --git a/libxslt/preproc.c b/libxslt/preproc.c
index b0685a40d7a572c1a2aee166a1261089fc150b6a_bGlieHNsdC9wcmVwcm9jLmM=..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_bGlieHNsdC9wcmVwcm9jLmM= 100644
--- a/libxslt/preproc.c
+++ b/libxslt/preproc.c
@@ -217,7 +217,10 @@
 xsltNewStylePreComp(xsltStylesheetPtr style, xsltStyleType type) {
     xsltStylePreCompPtr cur;
 
+    if (style == NULL)
+        return(NULL);
+
     cur = (xsltStylePreCompPtr) xmlMalloc(sizeof(xsltStylePreComp));
     if (cur == NULL) {
 	xsltTransformError(NULL, style, NULL,
 		"xsltNewStylePreComp : malloc failed\n");
@@ -220,8 +223,8 @@
     cur = (xsltStylePreCompPtr) xmlMalloc(sizeof(xsltStylePreComp));
     if (cur == NULL) {
 	xsltTransformError(NULL, style, NULL,
 		"xsltNewStylePreComp : malloc failed\n");
-	if (style != NULL) style->errors++;
+	style->errors++;
 	return(NULL);
     }
     memset(cur, 0, sizeof(xsltStylePreComp));
@@ -275,7 +278,7 @@
 	if (cur->func == NULL) {
 	    xsltTransformError(NULL, style, NULL,
 		    "xsltNewStylePreComp : no function for type %d\n", type);
-	    if (style != NULL) style->errors++;
+	    style->errors++;
 	}
     }
     cur->next = style->preComps;
diff --git a/libxslt/transform.c b/libxslt/transform.c
index b0685a40d7a572c1a2aee166a1261089fc150b6a_bGlieHNsdC90cmFuc2Zvcm0uYw==..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_bGlieHNsdC90cmFuc2Zvcm0uYw== 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -758,6 +758,6 @@
 	ctxt->lasttuse = len;
     }
     if (copy != NULL) {
-        copy->doc = target->doc;
-	if (target != NULL)
+	if (target != NULL) {
+	    copy->doc = target->doc;
 	    xmlAddChild(target, copy);
@@ -763,4 +763,5 @@
 	    xmlAddChild(target, copy);
+	}
     } else {
 	xsltTransformError(ctxt, NULL, target,
 			 "xsltCopyText: text copy failed\n");
@@ -857,7 +858,7 @@
 	     xmlNodePtr insert) {
     xmlNodePtr copy;
 
-    if (node->type == XML_DTD_NODE)
+    if ((node->type == XML_DTD_NODE) || (insert == NULL))
 	return(NULL);
     if ((node->type == XML_TEXT_NODE) ||
 	(node->type == XML_CDATA_SECTION_NODE))
@@ -877,8 +878,8 @@
 	     (node->type == XML_ATTRIBUTE_NODE)) {
 	    if (node->ns != NULL) {
 		copy->ns = xsltGetNamespace(ctxt, node, node->ns, copy);
-	    } else if ((insert != NULL) && (insert->type == XML_ELEMENT_NODE) &&
-		     (insert->ns != NULL)) {
+	    } else if ((insert->type == XML_ELEMENT_NODE) &&
+		       (insert->ns != NULL)) {
 		xmlNsPtr defaultNs;
 
 		defaultNs = xmlSearchNs(insert->doc, insert, NULL);
@@ -1520,6 +1521,8 @@
 #endif
     long start = 0;
 
+    if (ctxt == NULL) return;
+
 #ifdef WITH_DEBUGGER
     if (ctxt->debugStatus != XSLT_DEBUG_NONE) {
         if (templ) {
@@ -1550,7 +1553,7 @@
     }
 #endif
 
-    if ((ctxt == NULL) || (list == NULL))
+    if (list == NULL)
         return;
     CHECK_STOPPED;
 
@@ -3497,7 +3500,6 @@
 void
 xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
 	   xmlNodePtr inst, xsltStylePreCompPtr comp ATTRIBUTE_UNUSED) {
-    xmlChar *prop = NULL;
     xmlXPathObjectPtr res = NULL;
     xmlNodePtr replacement, when;
     int doit = 1;
@@ -3587,9 +3589,6 @@
 		                 NULL, NULL, 0);
 	    goto done;
 	}
-	if (prop != NULL)
-	    xmlFree(prop);
-	prop = NULL;
 	if (res != NULL)
 	    xmlXPathFreeObject(res);
 	res = NULL;
@@ -3620,8 +3619,6 @@
 
 done:
 error:
-    if (prop != NULL)
-	xmlFree(prop);
     if (res != NULL)
 	xmlXPathFreeObject(res);
 }
@@ -3714,7 +3711,7 @@
     xmlNodePtr replacement;
     xmlNodeSetPtr list = NULL, oldList;
     int i, oldProximityPosition, oldContextSize;
-    xmlNodePtr oldNode = ctxt->node;
+    xmlNodePtr oldNode;
     int nbsorts = 0;
     xmlNodePtr sorts[XSLT_MAX_SORT];
     xmlDocPtr oldXDocPtr;
@@ -3729,6 +3726,7 @@
 	     "xsl:for-each : compilation failed\n");
 	return;
     }
+    oldNode = ctxt->node;
 
 #ifdef WITH_XSLT_DEBUG_PROCESS
     XSLT_TRACE(ctxt,XSLT_TRACE_FOR_EACH,xsltGenericDebug(xsltGenericDebugContext,
@@ -4303,7 +4301,7 @@
     if ((res != NULL) && (ctxt != NULL) && (output != NULL)) {
 	int ret;
 
-	ret = xsltCheckWrite(userCtxt->sec, userCtxt, (const xmlChar *) output);
+	ret = xsltCheckWrite(ctxt->sec, ctxt, (const xmlChar *) output);
 	if (ret == 0) {
 	    xsltTransformError(ctxt, NULL, NULL,
 		     "xsltApplyStylesheet: forbidden to save to %s\n",
diff --git a/libxslt/variables.c b/libxslt/variables.c
index b0685a40d7a572c1a2aee166a1261089fc150b6a_bGlieHNsdC92YXJpYWJsZXMuYw==..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_bGlieHNsdC92YXJpYWJsZXMuYw== 100644
--- a/libxslt/variables.c
+++ b/libxslt/variables.c
@@ -477,8 +477,12 @@
 	if ((precomp == NULL) || (precomp->comp == NULL))
 	    xmlXPathFreeCompExpr(comp);
 	if (result == NULL) {
-	    xsltTransformError(ctxt, NULL, precomp->inst,
-		"Evaluating variable %s failed\n", elem->name);
+	    if (precomp == NULL)
+		xsltTransformError(ctxt, NULL, NULL,
+		    "Evaluating variable %s failed\n", elem->name);
+	    else
+		xsltTransformError(ctxt, NULL, precomp->inst,
+		    "Evaluating variable %s failed\n", elem->name);
 	    ctxt->state = XSLT_STATE_STOPPED;
 #ifdef WITH_XSLT_DEBUG_VARIABLE
 #ifdef LIBXML_DEBUG_ENABLED
@@ -617,8 +621,12 @@
 	if ((precomp == NULL) || (precomp->comp == NULL))
 	    xmlXPathFreeCompExpr(comp);
 	if (result == NULL) {
-	    xsltTransformError(ctxt, NULL, precomp->inst,
-		"Evaluating global variable %s failed\n", elem->name);
+	    if (precomp == NULL)
+		xsltTransformError(ctxt, NULL, NULL,
+		    "Evaluating global variable %s failed\n", elem->name);
+	    else
+		xsltTransformError(ctxt, NULL, precomp->inst,
+		    "Evaluating global variable %s failed\n", elem->name);
 	    ctxt->state = XSLT_STATE_STOPPED;
 #ifdef WITH_XSLT_DEBUG_VARIABLE
 #ifdef LIBXML_DEBUG_ENABLED
@@ -1021,11 +1029,8 @@
     elem = xsltNewStackElem();
     if (elem != NULL) {
 	elem->name = name;
-	if (value != NULL)
-	    elem->select = xmlDictLookup(ctxt->dict, value, -1);
-	else
-	    elem->select = NULL;
-	if (href)
+	elem->select = xmlDictLookup(ctxt->dict, value, -1);
+	if (href != NULL)
 	    elem->nameURI = xmlDictLookup(ctxt->dict, href, -1);
 	elem->tree = NULL;
 	elem->computed = 1;
diff --git a/libxslt/xslt.c b/libxslt/xslt.c
index b0685a40d7a572c1a2aee166a1261089fc150b6a_bGlieHNsdC94c2x0LmM=..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_bGlieHNsdC94c2x0LmM= 100644
--- a/libxslt/xslt.c
+++ b/libxslt/xslt.c
@@ -1198,8 +1198,11 @@
     xmlNodePtr delete;
     int internalize = 0;
 
-    if ((style != NULL) && (cur != NULL) && (cur->doc != NULL) &&
-        (style->dict != NULL) && (cur->doc->dict == style->dict))
+    if ((style == NULL) || (cur == NULL))
+        return;
+
+    if ((cur->doc != NULL) && (style->dict != NULL) &&
+        (cur->doc->dict == style->dict))
 	internalize = 1;
     else
         style->internalized = 0;
@@ -1393,6 +1396,8 @@
     xmlNodePtr cur;
     const xmlChar *URI;
 
+    if (style == NULL)
+        return;
     /* 
      * TODO: basically if the stylesheet uses the same prefix for different
      *       patterns, well they may be in problem, hopefully they will get
@@ -1409,7 +1414,7 @@
 			if (style->nsHash == NULL) {
 			    xsltTransformError(NULL, style, cur,
 		 "xsltGatherNamespaces: failed to create hash table\n");
-			    if (style != NULL) style->errors++;
+			    style->errors++;
 			    return;
 			}
 		    }
@@ -1417,7 +1422,7 @@
 		    if ((URI != NULL) && (!xmlStrEqual(URI, ns->href))) {
 			xsltTransformError(NULL, style, cur,
 	     "Namespaces prefix %s used for multiple namespaces\n",ns->prefix);
-			if (style != NULL) style->warnings++;
+			style->warnings++;
 		    } else if (URI == NULL) {
 			xmlHashUpdateEntry(style->nsHash, ns->prefix,
 			    (void *) ns->href, (xmlHashDeallocator)xmlFree);
@@ -1513,7 +1518,7 @@
 						(const xmlChar *)"no")){
 			    xsltTransformError(NULL, style, cur,
 	     "xsl:text: disable-output-escaping allows only yes or no\n");
-			    if (style != NULL) style->warnings++;
+			    style->warnings++;
 
 			}
 			xmlFree(prop);
@@ -1528,7 +1533,7 @@
 			     (text->type != XML_CDATA_SECTION_NODE)) {
 			    xsltTransformError(NULL, style, cur,
 		 "xsltParseTemplateContent: xslt:text content problem\n");
-			    if (style != NULL) style->errors++;
+			    style->errors++;
 			    break;
 			}
 			if ((noesc) && (text->type != XML_CDATA_SECTION_NODE))
@@ -1540,14 +1545,6 @@
 		     * replace xsl:text by the list of childs
 		     */
 		    if (text == NULL) {
-		        int internalize = 0;
-			if ((style != NULL) && (text != NULL) &&
-			    (text->doc != NULL) && (style->dict != NULL) &&
-			    (text->doc->dict == style->dict))
-			    internalize = 1;
-			else
-			    style->internalized = 0;
-
 			text = cur->children;
 			while (text != NULL) {
 			    if ((text->content != NULL) &&
diff --git a/libxslt/xsltutils.c b/libxslt/xsltutils.c
index b0685a40d7a572c1a2aee166a1261089fc150b6a_bGlieHNsdC94c2x0dXRpbHMuYw==..7fc1b306dd36fb2dc56a4fdedf9dc4adb7056d25_bGlieHNsdC94c2x0dXRpbHMuYw== 100644
--- a/libxslt/xsltutils.c
+++ b/libxslt/xsltutils.c
@@ -286,7 +286,8 @@
     return(c);
 
 error:
-    *len = 0;
+    if (len != NULL)
+	*len = 0;
     return(-1);
 }