cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: multi_threads

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 6 Dec 2005 23:27:50 +0100 (CET)

On Tue, 6 Dec 2005, Brian Dessent wrote:

>> 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.

Even worse: When the loop hits the end of the file, it *will* unconditionally
call curl_easy_cleanup() on the same handle it already did curl_easy_cleanup()
on and I'm quite sure this will cause havoc...

-- 
  Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Received on 2005-12-06