cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: multi_threads

From: Brian Dessent <brian_at_dessent.net>
Date: Tue, 06 Dec 2005 13:00:01 -0800

Yi Li wrote:

> void *pull_one_url(void *)
> {
>
> CURL *curl; /// HMMM
> ...
> while(true){
>
> //get url
> pthread_mutex_lock(&locker);
> if(!fgets(line,4096,input)){
> curl_easy_cleanup(curl); /// <-- OUCH

If the stream is already at EOF when this code runs for the first time
in a given thread then you end up calling curl_easy_cleanup() on the
uninitialized variable which is undefined behavior.

Brian
Received on 2005-12-06