curl-library
Re: bug in cookie_add
Date: Mon, 7 Jan 2002 10:53:40 +0100 (MET)
On Mon, 7 Jan 2002, T. Bharath wrote:
> As a further note i believe the reason it gets in to the loop and then into
> if(replace_old) { the second time is because we dont reset replace_old
> I think we need to reset that in
> if(replace_old) {
> co->next = clist->next; /* get the next-pointer first */
> ...
> + replace_old = FALSE;
> }
>
> Am I right
(First, thanks again for your clever insights.)
You shouldn't ever get into that block a second time, as that would indicate
that we have the same cookie in the list more than once.
Anyway, I suggest that we instead of what you suggest (which probably won't
be any good because the conditional check at the end of the function checks
replace_old and it'll behave badly if it isn't "correct), just loop through
the list to get the 'lastc' pointer set correct. Like this:
--- cookie.c 2001/10/30 12:08:17 1.26
+++ cookie.c 2002/01/07 09:52:55
@@ -377,8 +377,15 @@
free(co); /* free the newly alloced memory */
co = clist; /* point to the previous struct instead */
- }
+ /* We have replaced a cookie, now skip the rest of the list but
+ make sure the 'lastc' pointer is properly set */
+ do {
+ lastc = clist;
+ clist = clist->next;
+ } while(clist);
+ break;
+ }
}
lastc = clist;
clist = clist->next;
Commmets?
-- Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/Received on 2002-01-07