fixed a couple of problems in xmlSetProp() Daniel

* tree.c: fixed a couple of problems in xmlSetProp()
Daniel
diff --git a/ChangeLog b/ChangeLog
index 3db9cab..48e57ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sun Nov 25 11:34:24 CET 2001 Daniel Veillard <daniel@veillard.com>
+
+	* tree.c: fixed a couple of problems in xmlSetProp()
+
 Thu Nov 22 19:19:10 CET 2001 Daniel Veillard <daniel@veillard.com>
 
 	* debugXML.c tree.c xmlIO.c xmlmemory.c: some cleanups when chasing
diff --git a/tree.c b/tree.c
index 12a8333..17a63e9 100644
--- a/tree.c
+++ b/tree.c
@@ -4485,17 +4485,18 @@
  */
 xmlAttrPtr
 xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
-    xmlAttrPtr prop = node->properties;
-    xmlDocPtr doc = NULL;
+    xmlAttrPtr prop;
+    xmlDocPtr doc;
 
     if ((node == NULL) || (name == NULL))
 	return(NULL);
     doc = node->doc;
+    prop = node->properties;
     while (prop != NULL) {
         if ((xmlStrEqual(prop->name, name)) &&
 	    (prop->ns == NULL)){
-	    if (prop->children != NULL) 
-	        xmlFreeNodeList(prop->children);
+	    xmlNodePtr oldprop = prop->children;
+
 	    prop->children = NULL;
 	    prop->last = NULL;
 	    if (value != NULL) {
@@ -4516,6 +4517,8 @@
 		}
 		xmlFree(buffer);
 	    }
+	    if (oldprop != NULL) 
+	        xmlFreeNodeList(oldprop);
 	    return(prop);
 	}
 	prop = prop->next;