Hi devs,
When using multi and schannel (version 7.40), it happens that
Curl_schannel_session_free (curl_schannel.c) can be called just after a
curl_easy_cleanup but before the Curl_schannel_shutdown is done on a
connection. It results that if the ssl credentials are cached, the refcount
will not be 0. And then, they are not be freed.
Furthermore, no leak happens when using openSSL. Here's how I managed to
counter the leak when using schannel:
(urldata.h)
struct curl_schannel_cred {
/* . */
bool session_freed; ///New boolean
/* . */
(curl_schannel.h)
void Curl_schannel_session_free(void *ptr)
{
struct curl_schannel_cred *cred = ptr;
if(cred && cred->cached)
{
if(cred->refcount == 0)
{
s_pSecFn->FreeCredentialsHandle(&cred->cred_handle);
Curl_safefree(cred);
}
else
{
cred->session_freed = true;
}
}
}
int Curl_schannel_shutdown(struct connectdata *conn, int sockindex)
/* . */
/* if the handle was not cached and the refcount is zero */
if((!connssl->cred->cached && connssl->cred->refcount == 0) ||
connssl->cred->session_freed) {
infof(data, "schannel: clear credential handle\n");
s_pSecFn->FreeCredentialsHandle(&connssl->cred->cred_handle);
Curl_safefree(connssl->cred);
}
/* . */
Any thoughts or suggestions are welcome,
Have a wonderful day,
--
Jean-Francois Durand
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html