Ecore_Con_Url/Curl: add referencing on _c structure

The _c structure used to store the Curl function pointers needs
referencing to be sure it is not freed although still needed.
The non-referencing was leading to a crash during the destruction
of the dialers. The _c was still used although it has been freed
by ecore_con_url_shutdown.
This commit is contained in:
Daniel Zaoui 2016-12-23 22:53:52 +02:00
parent 757cc83413
commit 3235c83c36
2 changed files with 9 additions and 2 deletions

View File

@ -244,7 +244,11 @@ _c_init(void)
{
long ms = 0;
if (_c) return EINA_TRUE;
if (_c)
{
_c->ref++;
return EINA_TRUE;
}
if (_c_fail)
{
ERR("Cannot find libcurl at runtime!");
@ -252,6 +256,7 @@ _c_init(void)
}
_c = calloc(1, sizeof(Ecore_Con_Curl));
if (!_c) goto error;
_c->ref++;
#define LOAD(x) \
if (!_c->mod) { \
@ -342,7 +347,7 @@ error:
void
_c_shutdown(void)
{
if (!_c) return;
if (!_c || _c->ref--) return;
if (_c->_curlm)
{
_c->curl_multi_cleanup(_c->_curlm);

View File

@ -451,6 +451,8 @@ struct _Ecore_Con_Curl
const char *string);
time_t (*curl_getdate)(const char *p, const time_t *unused);
curl_version_info_data *(*curl_version_info)(CURLversion);
int ref; /* Reference on the structure */
};
#define CURL_MIN_TIMEOUT 100