diff options
author | Stefan Eissing <stefan@eissing.org> | 2023-03-22 10:25:24 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2023-03-22 13:57:20 +0100 |
commit | 5d1ecbcbd2eaea80485374afff09d04245e05e63 (patch) | |
tree | 42dbbbbd73668c6b8a14a7d7092985214fc3f7fe /lib/urldata.h | |
parent | 8a83bda0a2b013aa32a9de38e91f411069fec0ac (diff) | |
download | curl-5d1ecbcbd2eaea80485374afff09d04245e05e63.tar.gz |
multi: add handle asserts in DEBUG builds
For GOOD_EASY_HANDLE and GOOD_MULTI_HANDLE checks
- allow NULL pointers to "just" return an error as before
- fail hard on nun-NULL pointers that no longer show the MAGICs
Closes #10812
Diffstat (limited to 'lib/urldata.h')
-rw-r--r-- | lib/urldata.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/urldata.h b/lib/urldata.h index 8b54518d2..86b3da718 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -208,8 +208,17 @@ typedef CURLcode (*Curl_datastream)(struct Curl_easy *data, #define UPLOADBUFFER_MIN CURL_MAX_WRITE_SIZE #define CURLEASY_MAGIC_NUMBER 0xc0dedbadU +#ifdef DEBUGBUILD +/* On a debug build, we want to fail hard on easy handles that + * are not NULL, but no longer have the MAGIC touch. This gives + * us early warning on things only discovered by valgrind otherwise. */ +#define GOOD_EASY_HANDLE(x) \ + (((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER))? TRUE: \ + (DEBUGASSERT(!(x)), FALSE)) +#else #define GOOD_EASY_HANDLE(x) \ ((x) && ((x)->magic == CURLEASY_MAGIC_NUMBER)) +#endif #ifdef HAVE_GSSAPI /* Types needed for krb5-ftp connections */ |