aliyun / aliyun-oss-cpp-sdk

Aliyun OSS SDK for C++
Other
184 stars 88 forks source link

oss CurlHttpClient::makeRequest源码 有关curl相关内存释放的问题 #145

Closed zchGithub123 closed 1 year ago

zchGithub123 commented 1 year ago

list = curl_slist_append(list, str.c_str());
list = curl_slist_append(list, "Expect:"); curl_easy_setopt(curl, CURLOPTHTTPHEADER, list); curlContainer->Release(curl, (res != CURLE_OK)); curl_slist_free_all(list);

以上是CurlHttpClient::makeRequest方法里面的一些代码,如果!!!,res != CURLE_OK发生,Release里面的curl_easy_cleanup被调用,curl_slist_free_all去释放list还能安全吗。

查得libcurl里面有关curl_easy_cleanup这个api的一句描述,如下

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方法被返回后,所有与之curl handle 关联的内存都被kills。