applied patch from Florent Guilian to remove an useless mutex in the

* dict.c: applied patch from Florent Guilian to remove an
  useless mutex in the xmlDict structure.

older, not commited ...

* SAX2.c: another leak reported by Ashwin
* xinclude.c: fixed the behaviour when XIncluding a fragment
  of the current document, patch from Chris Ryan

Daniel


svn path=/trunk/; revision=3686
diff --git a/ChangeLog b/ChangeLog
index 7d0649c..112c1b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Fri Feb  8 10:54:09 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+	* dict.c: applied patch from Florent Guilian to remove an
+	  useless mutex in the xmlDict structure.
+
+Wed Feb  6 17:00:20 CET 2008 Daniel Veillard <daniel@veillard.com>
+
+	* SAX2.c: another leak reported by Ashwin
+	* xinclude.c: fixed the behaviour when XIncluding a fragment
+	  of the current document, patch from Chris Ryan
+
 Wed Feb  6 12:10:08 HKT 2008 William Brack <wbrack@mmm.com.hk>
 
 	* nanohttp.c: added space for port number (when not 80) in
diff --git a/SAX2.c b/SAX2.c
index 9739831..7dbc2b2 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -2366,7 +2366,9 @@
     xmlGenericError(xmlGenericErrorContext,
 	    "add xmlSAX2Reference %s to %s \n", name, ctxt->node->name);
 #endif
-    xmlAddChild(ctxt->node, ret);
+    if (xmlAddChild(ctxt->node, ret) == NULL) {
+        xmlFreeNode(ret);
+    }
 }
 
 /**
diff --git a/dict.c b/dict.c
index 3b4054f..c071887 100644
--- a/dict.c
+++ b/dict.c
@@ -60,7 +60,6 @@
  */
 struct _xmlDict {
     int ref_counter;
-    xmlRMutexPtr mutex;
 
     struct _xmlDictEntry *dict;
     int size;
@@ -337,11 +336,8 @@
 	dict->strings = NULL;
 	dict->subdict = NULL;
         if (dict->dict) {
-            if ((dict->mutex = xmlNewRMutex()) != NULL) {
-                memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
-                return(dict);
-            }
-            xmlFree(dict->dict);
+	    memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
+	    return(dict);
         }
         xmlFree(dict);
     }
@@ -545,7 +541,6 @@
 	xmlFree(pool);
 	pool = nextp;
     }
-    xmlFreeRMutex(dict->mutex);
     xmlFree(dict);
 }
 
diff --git a/xinclude.c b/xinclude.c
index 31ea026..2310601 100644
--- a/xinclude.c
+++ b/xinclude.c
@@ -516,9 +516,8 @@
 	href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */
 	if (href == NULL) 
 	    return(-1);
-	local = 1;
     }
-    if (href[0] == '#')
+    if ((href[0] == '#') || (href[0] == 0))
 	local = 1;
     parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE);
     if (parse != NULL) {
@@ -617,6 +616,19 @@
     }
 
     /*
+     * If local and xml then we need a fragment
+     */
+    if ((local == 1) && (xml == 1) &&
+        ((fragment == NULL) || (fragment[0] == 0))) {
+	xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_RECURSION,
+	               "detected a local recursion with no xpointer in %s\n",
+		       URL);
+	if (fragment != NULL)
+	    xmlFree(fragment);
+	return(-1);
+    }
+
+    /*
      * Check the URL against the stack for recursions
      */
     if ((!local) && (xml == 1)) {