Dmitriy Sergeyev provided an example source code that crashed CVS libcurl

but that worked nicely in 7.15.5. I converted it into test case 532 and
fixed the problem.
This commit is contained in:
Daniel Stenberg
2006-10-04 21:11:08 +00:00
parent e2b48366d3
commit 552b963e6d
7 changed files with 128 additions and 10 deletions

View File

@@ -351,6 +351,8 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle,
{
struct Curl_multi *multi=(struct Curl_multi *)multi_handle;
struct Curl_one_easy *easy;
struct closure *cl;
struct closure *prev=NULL;
/* First, make some basic checks that the CURLM handle is a good handle */
if(!GOOD_MULTI_HANDLE(multi))
@@ -368,7 +370,21 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle,
if(!easy)
return CURLM_OUT_OF_MEMORY;
easy->numsocks=0;
cl = multi->closure;
while(cl) {
struct closure *next = cl->next;
if(cl->easy_handle == easy_handle) {
/* remove this handle from the closure list */
free(cl);
if(prev)
prev->next = next;
else
multi->closure = next;
break; /* no need to continue since this handle can only be present once
in the list */
}
cl = next;
}
/* set the easy handle */
easy->easy_handle = easy_handle;
@@ -1796,8 +1812,10 @@ static bool multi_conn_using(struct Curl_multi *multi,
return FALSE;
}
/* add the given data pointer to the list of 'closure handles' that are
kept around only to be able to close some connections nicely */
/* Add the given data pointer to the list of 'closure handles' that are kept
around only to be able to close some connections nicely - just make sure
that this handle isn't already added, like for the cases when an easy
handle is removed, added and removed again... */
static void add_closure(struct Curl_multi *multi,
struct SessionHandle *data)
{