curl / Mailing Lists / curl-library / Single Mail

curl-library

segfault when reuse curl_slist

From: Pahome Chen via curl-library <curl-library_at_cool.haxx.se>
Date: Fri, 5 May 2017 18:05:25 +0800

I create a variable curl_slist *header = NULL, and I want to reuse it.

*Error situation:*
*1st time:*
curl_slist_append(header, ...);
curl_easy_perform(curl);
curl_slist_free_all(header);

*reuse next time:*
curl_slist_append(header, ...);
curl_easy_perform(curl); // get segfault

*Correct situation:*
*1st time:*
curl_slist_append(header, ...);
curl_easy_perform(curl);
curl_slist_free_all(header);
*header = NULL; //add this line*

*reuse next time:*
curl_slist_append(header, ...);
curl_easy_perform(curl); // correct!

-- 
Best Regards,
pahome

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-05-05