summaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2019-10-28 09:28:05 +0100
committerDaniel Stenberg <daniel@haxx.se>2019-10-30 09:36:21 +0100
commitdcd7e37c3a0ce108635b89cacc1e3425e57bd3bc (patch)
tree97213435d44104e4217159001944504ce518158d /lib/url.c
parent4011802b35638e311e548e8893fa74373275145a (diff)
downloadcurl-dcd7e37c3a0ce108635b89cacc1e3425e57bd3bc.tar.gz
url: make Curl_close() NULLify the pointer too
This is the common pattern used in the code and by a unified approach we avoid mistakes. Closes #4534
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/url.c b/lib/url.c
index bbae273fd..8285474fd 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -317,13 +317,17 @@ static void up_free(struct Curl_easy *data)
* when curl_easy_perform() is invoked.
*/
-CURLcode Curl_close(struct Curl_easy *data)
+CURLcode Curl_close(struct Curl_easy **datap)
{
struct Curl_multi *m;
+ struct Curl_easy *data;
- if(!data)
+ if(!datap || !*datap)
return CURLE_OK;
+ data = *datap;
+ *datap = NULL;
+
Curl_expire_clear(data); /* shut off timers */
m = data->multi;
@@ -1983,10 +1987,8 @@ void Curl_free_request_state(struct Curl_easy *data)
{
Curl_safefree(data->req.protop);
Curl_safefree(data->req.newurl);
- Curl_close(data->req.doh.probe[0].easy);
- data->req.doh.probe[0].easy = NULL;
- Curl_close(data->req.doh.probe[1].easy);
- data->req.doh.probe[1].easy = NULL;
+ Curl_close(&data->req.doh.probe[0].easy);
+ Curl_close(&data->req.doh.probe[1].easy);
}