mirror of
https://github.com/Llewellynvdm/conky.git
synced 2025-01-13 19:22:58 +00:00
Fix segfault and memleaks in curl
This commit is contained in:
parent
3e4a2cf74e
commit
e292dd5e28
@ -122,6 +122,7 @@ void ccurl_fetch_data(ccurl_location_t *curloc)
|
||||
chunk.memory = NULL;
|
||||
chunk.size = 0;
|
||||
|
||||
if (curl_global_init(CURL_GLOBAL_ALL) == 0) {
|
||||
curl = curl_easy_init();
|
||||
if (curl) {
|
||||
DBGP("reading curl data from '%s'", curloc->uri);
|
||||
@ -133,9 +134,15 @@ void ccurl_fetch_data(ccurl_location_t *curloc)
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
if (res == CURLE_OK && chunk.size) {
|
||||
long http_status_code;
|
||||
|
||||
if(curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_status_code) == CURLE_OK && http_status_code == 200) {
|
||||
timed_thread_lock(curloc->p_timed_thread);
|
||||
(*curloc->process_function)(curloc->result, chunk.memory);
|
||||
timed_thread_unlock(curloc->p_timed_thread);
|
||||
} else {
|
||||
NORM_ERR("curl: no data from server");
|
||||
}
|
||||
free(chunk.memory);
|
||||
} else {
|
||||
NORM_ERR("curl: no data from server");
|
||||
@ -143,6 +150,8 @@ void ccurl_fetch_data(ccurl_location_t *curloc)
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
curl_global_cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
void *ccurl_thread(void *) __attribute__((noreturn));
|
||||
|
Loading…
Reference in New Issue
Block a user