diff options
author | Daniel Stenberg <daniel@haxx.se> | 2019-12-12 23:30:42 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2019-12-13 08:16:29 +0100 |
commit | f389953da0f9da754550f6f5540d44d7aaf2ea32 (patch) | |
tree | 7d9d2d9770e951b10dc2261bdde50203d954266e /tests | |
parent | 197d8aaf6db97db8ae06ccee828e7d6c46a22f4e (diff) | |
download | curl-f389953da0f9da754550f6f5540d44d7aaf2ea32.tar.gz |
unit1607: fix mem-leak in OOM
Closes #4709
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unit1607.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/tests/unit/unit1607.c b/tests/unit/unit1607.c index a8b0331ce..e8d412080 100644 --- a/tests/unit/unit1607.c +++ b/tests/unit/unit1607.c @@ -99,23 +99,23 @@ static const struct testcase tests[] = { }; UNITTEST_START +{ int i; int testnum = sizeof(tests) / sizeof(struct testcase); + struct Curl_multi *multi = NULL; + struct Curl_easy *easy = NULL; + struct curl_slist *list = NULL; for(i = 0; i < testnum; ++i) { int j; int addressnum = sizeof(tests[i].address) / sizeof(*tests[i].address); struct Curl_addrinfo *addr; struct Curl_dns_entry *dns; - struct curl_slist *list; void *entry_id; bool problem = false; - struct Curl_multi *multi; - struct Curl_easy *easy = curl_easy_init(); - if(!easy) { - curl_global_cleanup(); - return CURLE_OUT_OF_MEMORY; - } + easy = curl_easy_init(); + if(!easy) + goto error; /* create a multi handle and add the easy handle to it so that the hostcache is setup */ @@ -124,16 +124,14 @@ UNITTEST_START list = curl_slist_append(NULL, tests[i].optval); if(!list) - goto unit_test_abort; + goto error; curl_easy_setopt(easy, CURLOPT_RESOLVE, list); Curl_loadhostpairs(easy); entry_id = (void *)aprintf("%s:%d", tests[i].host, tests[i].port); - if(!entry_id) { - curl_slist_free_all(list); - goto unit_test_abort; - } + if(!entry_id) + goto error; dns = Curl_hash_pick(easy->dns.hostcache, entry_id, strlen(entry_id) + 1); free(entry_id); entry_id = NULL; @@ -202,12 +200,20 @@ UNITTEST_START } curl_easy_cleanup(easy); + easy = NULL; curl_multi_cleanup(multi); + multi = NULL; curl_slist_free_all(list); + list = NULL; if(problem) { unitfail++; continue; } } + error: + curl_easy_cleanup(easy); + curl_multi_cleanup(multi); + curl_slist_free_all(list); +} UNITTEST_STOP |