doh: fix cleanup

When removing an easy handle that had DoH sub-easy handles going, those
were not removed from the multi handle. Their memory was reclaimed on
curl_easy_cleanup() of the owning handle, but multi still had them in
their list.

Add `Curl_doh_close()` and `Curl_doh_cleanup()` as common point for
handling the DoH resource management. Use the `multi` present in the doh
handles (if so), for removal, as the `data->multi` might already have
been NULLed at this time.

Reported-by: 罗朝辉
Fixes #14207
Closes #14212
This commit is contained in:
Stefan Eissing 2024-07-17 14:46:47 +02:00 committed by Daniel Stenberg
parent 5eba0a4b37
commit d8696dc8c0
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
4 changed files with 37 additions and 24 deletions

View file

@ -2799,6 +2799,9 @@ CURLMcode curl_multi_cleanup(struct Curl_multi *multi)
/* First remove all remaining easy handles */
data = multi->easyp;
while(data) {
if(!GOOD_EASY_HANDLE(data))
return CURLM_BAD_HANDLE;
nextdata = data->next;
if(!data->state.done && data->conn)
/* if DONE was never called for this handle */