mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
Andrs Garca found out the share cleanup code crashes when you cleanup
and there are not lock/unlock functions set!
This commit is contained in:
parent
5a93f50394
commit
a9572bf88a
33
lib/share.c
33
lib/share.c
@ -1,8 +1,8 @@
|
|||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* _ _ ____ _
|
* _ _ ____ _
|
||||||
* Project ___| | | | _ \| |
|
* Project ___| | | | _ \| |
|
||||||
* / __| | | | |_) | |
|
* / __| | | | |_) | |
|
||||||
* | (__| |_| | _ <| |___
|
* | (__| |_| | _ <| |___
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
@ -10,7 +10,7 @@
|
|||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
* are also available at http://curl.haxx.se/docs/copyright.html.
|
* are also available at http://curl.haxx.se/docs/copyright.html.
|
||||||
*
|
*
|
||||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
* copies of the Software, and permit persons to whom the Software is
|
* copies of the Software, and permit persons to whom the Software is
|
||||||
* furnished to do so, under the terms of the COPYING file.
|
* furnished to do so, under the terms of the COPYING file.
|
||||||
@ -135,7 +135,7 @@ curl_share_setopt(CURLSH *sh, CURLSHoption option, ...)
|
|||||||
|
|
||||||
case CURLSHOPT_UNLOCKFUNC:
|
case CURLSHOPT_UNLOCKFUNC:
|
||||||
unlockfunc = va_arg(param, curl_unlock_function);
|
unlockfunc = va_arg(param, curl_unlock_function);
|
||||||
share->unlockfunc = unlockfunc;
|
share->unlockfunc = unlockfunc;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CURLSHOPT_USERDATA:
|
case CURLSHOPT_USERDATA:
|
||||||
@ -154,15 +154,17 @@ CURLSHcode
|
|||||||
curl_share_cleanup(CURLSH *sh)
|
curl_share_cleanup(CURLSH *sh)
|
||||||
{
|
{
|
||||||
struct Curl_share *share = (struct Curl_share *)sh;
|
struct Curl_share *share = (struct Curl_share *)sh;
|
||||||
|
|
||||||
if (share == NULL)
|
if (share == NULL)
|
||||||
return CURLSHE_INVALID;
|
return CURLSHE_INVALID;
|
||||||
|
|
||||||
share->lockfunc(NULL, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE,
|
if(share->lockfunc)
|
||||||
share->clientdata);
|
share->lockfunc(NULL, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE,
|
||||||
|
share->clientdata);
|
||||||
|
|
||||||
if (share->dirty) {
|
if (share->dirty) {
|
||||||
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
|
if(share->unlockfunc)
|
||||||
|
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
|
||||||
return CURLSHE_IN_USE;
|
return CURLSHE_IN_USE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,9 +176,10 @@ curl_share_cleanup(CURLSH *sh)
|
|||||||
Curl_cookie_cleanup(share->cookies);
|
Curl_cookie_cleanup(share->cookies);
|
||||||
#endif /* CURL_DISABLE_HTTP */
|
#endif /* CURL_DISABLE_HTTP */
|
||||||
|
|
||||||
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
|
if(share->unlockfunc)
|
||||||
free (share);
|
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
|
||||||
|
free(share);
|
||||||
|
|
||||||
return CURLSHE_OK;
|
return CURLSHE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user