Hello,

I think that I have discovered a small problem in curl_download.c code, can
you please verify? The problem is around line 220:

if (!handle)
   curl_easy_cleanup ( curl );
if (curl_send_headers) {
  curl_slist_free_all(curl_send_headers);
  curl_send_headers = NULL;
  curl_easy_setopt ( curl, CURLOPT_HTTPHEADER , NULL);
}

The code first runs curl_easy_cleanup() on curl handle, and later (if
curl_send_headers is true) the code also executes curl_easy_setopt() on the
previously cleaned-up curl handle.

The documentation for curl_easy_cleanup() (
https://curl.haxx.se/libcurl/c/curl_easy_cleanup.html) states:

"Any use of the handle after this function has been called and have
returned, is illegal. curl_easy_cleanup kills the handle and all memory
associated with it!"

curl_easy_cleanup() is also used in two other places. The second place
probably suffers from the same problem.

I didn't verify the third place where the function is called.
curl_easy_cleanup() is inside a wrapper that may be used in less obvious
ways. Perhaps setting the handle to NULL after
curl_easy_cleanup() and then testing if the handle is NULL would help
catching any problems caused by third call to curl_easy_cleanup().

Best regards,
Kamil
_______________________________________________
Viking-devel mailing list
Viking-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/viking-devel
Viking home page: http://viking.sf.net/

Reply via email to