applied patch to fix xmlListAppend() from Georges-André SILBER also fix

* list.c: applied patch to fix xmlListAppend() from 
  Georges-André SILBER
* valid.c: also fix the place wher it was called.
Daniel

svn path=/trunk/; revision=3614
diff --git a/ChangeLog b/ChangeLog
index a1af2f7..aecf060 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Thu May 10 01:52:42 CEST 2007 Daniel Veillard <daniel@veillard.com>
+
+	* list.c: applied patch to fix xmlListAppend() from 
+	  Georges-André SILBER
+	* valid.c: also fix the place wher it was called.
+
 Wed May  2 18:47:33 CEST 2007 Daniel Veillard <daniel@veillard.com>
 
 	* parser.c: tried to fix an error problem on entity content failure
diff --git a/list.c b/list.c
index 2dc6d96..5c01c83 100644
--- a/list.c
+++ b/list.c
@@ -314,14 +314,14 @@
     if (lkNew == NULL) {
         xmlGenericError(xmlGenericErrorContext, 
 		        "Cannot initialize memory for new link");
-        return (0);
+        return (1);
     }
     lkNew->data = data;
     lkNew->next = lkPlace->next;
     (lkPlace->next)->prev = lkNew;
     lkPlace->next = lkNew;
     lkNew->prev = lkPlace;
-    return 1;
+    return 0;
 }
 
 /**
diff --git a/valid.c b/valid.c
index a239e68..b035f62 100644
--- a/valid.c
+++ b/valid.c
@@ -2998,19 +2998,32 @@
 	    xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
 		    "xmlAddRef: Reference list creation failed!\n",
 		    NULL);
-            return(NULL);
+	    goto failed;
         }
         if (xmlHashAddEntry(table, value, ref_list) < 0) {
             xmlListDelete(ref_list);
 	    xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
 		    "xmlAddRef: Reference list insertion failed!\n",
 		    NULL);
-            return(NULL);
+	    goto failed;
         }
     }
-/*    xmlListInsert(ref_list, ret); */
-    xmlListAppend(ref_list, ret);
+    if (xmlListAppend(ref_list, ret) != 0) {
+	xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
+		    "xmlAddRef: Reference list insertion failed!\n",
+		    NULL);
+        goto failed;
+    }
     return(ret);
+failed:
+    if (ret != NULL) {
+        if (ret->value != NULL)
+	    xmlFree((char *)ret->value);
+        if (ret->name != NULL)
+	    xmlFree((char *)ret->name);
+        xmlFree(ret);
+    }
+    return(NULL);
 }
 
 /**