Ticket #458: curl_splay2.diff

File curl_splay2.diff, 2.1 KB (added by rakshasa, 6 years ago)

Well, they included my first fix in 7.15.5, but there were some more bugs fixed by this patch. It will be in the next release of curl.

  • curl/lib/splay.c

    RCS file: /cvsroot/curl/curl/lib/splay.c,v
    retrieving revision 1.3
    diff -u -r1.3 splay.c
     
    8080    else 
    8181      break; 
    8282  } 
    83   l->larger = r->smaller = NULL; 
    8483 
    8584  l->larger = t->smaller;                                /* assemble */ 
    8685  r->smaller = t->larger; 
     
    114113      t->smaller = node; /* in the sub node for this same key, we use the 
    115114                            smaller pointer to point back to the master 
    116115                            node */ 
     116 
    117117      t->key = KEY_NOTUSED; /* and we set the key in the sub node to NOTUSED 
    118118                               to quickly identify this node as a subnode */ 
    119119 
     
    270270    /* Key set to NOTUSED means it is a subnode within a 'same' linked list 
    271271       and thus we can unlink it easily. The 'smaller' link of a subnode 
    272272       links to the parent node. */ 
     273    if (remove->smaller == NULL) 
     274      return 3; 
     275 
    273276    remove->smaller->same = remove->same; 
    274277    if(remove->same) 
    275278      remove->same->smaller = remove->smaller; 
     279 
     280    /* Ensures that double-remove gets caught. */ 
     281    remove->smaller = NULL; 
     282 
    276283    /* voila, we're done! */ 
    277284    *newroot = t; /* return the same root */ 
    278285    return 0; 
     
    280287 
    281288  t = Curl_splay(remove->key, t); 
    282289 
    283   /* First make sure that we got a root node witht he same key as the one we 
    284      want to remove, as otherwise we might be trying to remove a node that 
    285      isn't actually in the tree. */ 
    286   if(t->key != remove->key) 
     290  /* First make sure that we got the same root node as the one we want 
     291     to remove, as otherwise we might be trying to remove a node that 
     292     isn't actually in the tree. 
     293 
     294     We cannot just compare the keys here as a double remove in quick 
     295     succession of a node with key != KEY_NOTUSED && same != NULL 
     296     could return the same key but a different node. */ 
     297  if(t != remove) 
    287298    return 2; 
    288299 
    289300  /* Check if there is a list with identical sizes, as then we're trying to