Index: curl/lib/splay.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/splay.c,v
retrieving revision 1.3
diff -u -r1.3 splay.c
--- curl/lib/splay.c	27 May 2006 22:25:55 -0000	1.3
+++ curl/lib/splay.c	16 Jul 2006 09:30:45 -0000
@@ -267,12 +267,19 @@
     return 1;
 
   if(KEY_NOTUSED == remove->key) {
+    if(remove->smaller == NULL)
+      return 4;
+
     /* Key set to NOTUSED means it is a subnode within a 'same' linked list
        and thus we can unlink it easily. The 'smaller' link of a subnode
        links to the parent node. */
     remove->smaller->same = remove->same;
     if(remove->same)
       remove->same->smaller = remove->smaller;
+
+    /* Cleanup in case this node is attempted removed twice. */
+    remove->smaller = NULL;
+
     /* voila, we're done! */
     *newroot = t; /* return the same root */
     return 0;
@@ -280,10 +287,10 @@
 
   t = Curl_splay(remove->key, t);
 
-  /* First make sure that we got a root node witht he same key as the one we
-     want to remove, as otherwise we might be trying to remove a node that
-     isn't actually in the tree. */
-  if(t->key != remove->key)
+  /* First make sure that we got a root node which is the same as the
+     one we want to remove, as otherwise we might be trying to remove
+     a node that isn't actually in the tree. */
+  if(t != remove)
     return 2;
 
   /* Check if there is a list with identical sizes, as then we're trying to
