diff options
author | Daniel Stenberg <daniel@haxx.se> | 2021-01-05 00:03:57 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2021-01-06 15:13:45 +0100 |
commit | 9d7281ff1787d83e8e96bb3fc9441ae4cba0cd08 (patch) | |
tree | 67331fe69c52cbdc502e6cc24a003c19f9556a32 /lib/easy.c | |
parent | 75f7ab28d20ba0d099e23568109f3f3e6cd95d1b (diff) | |
download | curl-9d7281ff1787d83e8e96bb3fc9441ae4cba0cd08.tar.gz |
global_init: debug builds allocates a byte in init
... to make build tools/valgrind warn if no curl_global_cleanup is
called.
This is conditionally only done for debug builds with the env variable
CURL_GLOBAL_INIT set.
Closes #6410
Diffstat (limited to 'lib/easy.c')
-rw-r--r-- | lib/easy.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/easy.c b/lib/easy.c index 311946bdf..04e59144b 100644 --- a/lib/easy.c +++ b/lib/easy.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 @@ -124,6 +124,10 @@ curl_wcsdup_callback Curl_cwcsdup = (curl_wcsdup_callback)_wcsdup; # pragma warning(default:4232) /* MSVC extension, dllimport identity */ #endif +#ifdef DEBUGBUILD +static char *leakpointer; +#endif + /** * curl_global_init() globally initializes curl given a bitwise set of the * different features of what to initialize. @@ -190,6 +194,12 @@ static CURLcode global_init(long flags, bool memoryfuncs) init_flags = flags; +#ifdef DEBUGBUILD + if(getenv("CURL_GLOBAL_INIT")) + /* alloc data that will leak if *cleanup() is not called! */ + leakpointer = malloc(1); +#endif + return CURLE_OK; fail: @@ -265,6 +275,9 @@ void curl_global_cleanup(void) #ifdef USE_WOLFSSH (void)wolfSSH_Cleanup(); #endif +#ifdef DEBUGBUILD + free(leakpointer); +#endif init_flags = 0; } |