summaryrefslogtreecommitdiff
path: root/lib/share.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/share.c')
-rw-r--r--lib/share.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/share.c b/lib/share.c
index 5ce983033..4f1804dbd 100644
--- a/lib/share.c
+++ b/lib/share.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -37,6 +37,7 @@ curl_share_init(void)
{
struct Curl_share *share = calloc(1, sizeof(struct Curl_share));
if(share) {
+ share->magic = CURL_GOOD_SHARE;
share->specifier |= (1<<CURL_LOCK_DATA_SHARE);
if(Curl_mk_dnscache(&share->hostcache)) {
@@ -59,6 +60,9 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
void *ptr;
CURLSHcode res = CURLSHE_OK;
+ if(!GOOD_SHARE_HANDLE(share))
+ return CURLSHE_INVALID;
+
if(share->dirty)
/* don't allow setting options while one or more handles are already
using this share */
@@ -184,7 +188,7 @@ curl_share_setopt(struct Curl_share *share, CURLSHoption option, ...)
CURLSHcode
curl_share_cleanup(struct Curl_share *share)
{
- if(share == NULL)
+ if(!GOOD_SHARE_HANDLE(share))
return CURLSHE_INVALID;
if(share->lockfunc)
@@ -218,6 +222,7 @@ curl_share_cleanup(struct Curl_share *share)
if(share->unlockfunc)
share->unlockfunc(NULL, CURL_LOCK_DATA_SHARE, share->clientdata);
+ share->magic = 0;
free(share);
return CURLSHE_OK;