diff options
author | Andrei Sedoi <bsnote@gmail.com> | 2016-11-02 09:00:20 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-11-03 12:32:14 +0100 |
commit | e6882ce4846622dab5bef8b0e566062057068bc6 (patch) | |
tree | c18f2ea83dd1445d242489805a37ac69398d5087 /docs | |
parent | b1aeed302d52e2663722ef8694cd4d0f06e38bdf (diff) |
docs: multi-uv: don't use CURLMsg after cleanup
Diffstat (limited to 'docs')
-rw-r--r-- | docs/examples/multi-uv.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c index f74ae2880..aece4011a 100644 --- a/docs/examples/multi-uv.c +++ b/docs/examples/multi-uv.c @@ -104,18 +104,25 @@ static void check_multi_info(void) char *done_url; CURLMsg *message; int pending; + CURL *easy_handle; FILE *file; while((message = curl_multi_info_read(curl_handle, &pending))) { switch(message->msg) { case CURLMSG_DONE: - curl_easy_getinfo(message->easy_handle, CURLINFO_EFFECTIVE_URL, - &done_url); - curl_easy_getinfo(message->easy_handle, CURLINFO_PRIVATE, &file); + /* Do not use message data after calling curl_multi_remove_handle() and + curl_easy_cleanup(). As per curl_multi_info_read() docs: + "WARNING: The data the returned pointer points to will not survive + calling curl_multi_cleanup, curl_multi_remove_handle or + curl_easy_cleanup." */ + easy_handle = message->easy_handle; + + curl_easy_getinfo(easy_handle, CURLINFO_EFFECTIVE_URL, &done_url); + curl_easy_getinfo(easy_handle, CURLINFO_PRIVATE, &file); printf("%s DONE\n", done_url); - curl_multi_remove_handle(curl_handle, message->easy_handle); - curl_easy_cleanup(message->easy_handle); + curl_multi_remove_handle(curl_handle, easy_handle); + curl_easy_cleanup(easy_handle); if(file) { fclose(file); } |