From a9572bf88ae9d1efcdbc77b04ee88badfae3efbb Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 2 Jul 2004 08:28:31 +0000 Subject: =?UTF-8?q?Andr=E9s=20Garc=EDa=20found=20out=20the=20share=20clean?= =?UTF-8?q?up=20code=20crashes=20when=20you=20cleanup=20and=20there=20are?= =?UTF-8?q?=20not=20lock/unlock=20functions=20set!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/share.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/share.c b/lib/share.c index ad68496f6..5c01845df 100644 --- a/lib/share.c +++ b/lib/share.c @@ -1,8 +1,8 @@ /*************************************************************************** - * _ _ ____ _ - * Project ___| | | | _ \| | - * / __| | | | |_) | | - * | (__| |_| | _ <| |___ + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2004, Daniel Stenberg, , et al. @@ -10,7 +10,7 @@ * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://curl.haxx.se/docs/copyright.html. - * + * * 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 * 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: unlockfunc = va_arg(param, curl_unlock_function); - share->unlockfunc = unlockfunc; + share->unlockfunc = unlockfunc; break; case CURLSHOPT_USERDATA: @@ -154,15 +154,17 @@ CURLSHcode curl_share_cleanup(CURLSH *sh) { struct Curl_share *share = (struct Curl_share *)sh; - + if (share == NULL) return CURLSHE_INVALID; - - share->lockfunc(NULL, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE, - share->clientdata); - + + if(share->lockfunc) + share->lockfunc(NULL, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE, + share->clientdata); + 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; } @@ -174,9 +176,10 @@ curl_share_cleanup(CURLSH *sh) Curl_cookie_cleanup(share->cookies); #endif /* CURL_DISABLE_HTTP */ - share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata); - free (share); - + if(share->unlockfunc) + share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata); + free(share); + return CURLSHE_OK; } -- cgit v1.2.3