summaryrefslogtreecommitdiff
path: root/lib/setopt.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-01-19 08:23:52 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-01-19 08:41:29 +0100
commitabc52bf7cbf300eacabbaf642a0a9ac7af99ddc2 (patch)
treea72fc642f34c95eeeba4fd7ed3d100739596967b /lib/setopt.c
parent8399d89360db40cafe16ba65b5d9586d5a4fd3eb (diff)
downloadcurl-abc52bf7cbf300eacabbaf642a0a9ac7af99ddc2.tar.gz
urldata: make magic be the first struct fieldbagder/handle-diff
By making the `magic` identifier the same size and at the same place within the structs (easy, multi, share), libcurl will be able to more reliably detect and safely error out if an application passes in the wrong handle to APIs. Easier to detect and less likely to cause crashes if done. Such mixups can't be detected at compile-time due to them being typedefed void pointers - unless `CURL_STRICTER` is defined.
Diffstat (limited to 'lib/setopt.c')
-rw-r--r--lib/setopt.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/setopt.c b/lib/setopt.c
index 731ffeb36..409234fcd 100644
--- a/lib/setopt.c
+++ b/lib/setopt.c
@@ -2169,8 +2169,9 @@ CURLcode Curl_vsetopt(struct Curl_easy *data, CURLoption option, va_list param)
data->share = NULL;
}
- /* use new share if it set */
- data->share = set;
+ if(GOOD_SHARE_HANDLE(set))
+ /* use new share if it set */
+ data->share = set;
if(data->share) {
Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE);