mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-27 04:32:55 +00:00
Fix segfault in ccurl_thread.c
curl_global_init() is not thread-safe, it must be called at the start of main()
This commit is contained in:
parent
dadc49b09f
commit
3f7be35406
@ -122,7 +122,6 @@ 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);
|
||||
@ -150,8 +149,6 @@ void ccurl_fetch_data(ccurl_location_t *curloc)
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
curl_global_cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
void *ccurl_thread(void *) __attribute__((noreturn));
|
||||
|
12
src/conky.c
12
src/conky.c
@ -70,6 +70,9 @@
|
||||
#ifdef XOAP
|
||||
#include <libxml/parser.h>
|
||||
#endif /* XOAP */
|
||||
#ifdef HAVE_CURL
|
||||
#include <curl/curl.h>
|
||||
#endif
|
||||
|
||||
/* local headers */
|
||||
#include "core.h"
|
||||
@ -5894,6 +5897,11 @@ int main(int argc, char **argv)
|
||||
tcp_portmon_set_max_connections(0);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
if(curl_global_init(CURL_GLOBAL_ALL))
|
||||
NORM_ERR("curl_global_init() failed, you may not be able to use curl variables");
|
||||
#endif
|
||||
|
||||
/* handle command line parameters that don't change configs */
|
||||
#ifdef X11
|
||||
if (((s = getenv("LC_ALL")) && *s) || ((s = getenv("LC_CTYPE")) && *s)
|
||||
@ -5985,6 +5993,10 @@ int main(int argc, char **argv)
|
||||
|
||||
main_loop();
|
||||
|
||||
#ifdef HAVE_CURL
|
||||
curl_global_cleanup();
|
||||
#endif
|
||||
|
||||
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
|
||||
kvm_close(kd);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user