easy_getinfo: check magic, Curl_close safety

Check the easy handles magic in calls to curl_easy_getinfo().
In Curl_close() clear the magic after DNS shutdown since we'd
like to see tracing for this.
When clearing the magic, also clear the verbose flag so we
no longer call DEBUGFUNCTION on such a handle.

Closes #18511
This commit is contained in:
Stefan Eissing 2025-09-10 11:33:36 +02:00 committed by Daniel Stenberg
parent f4758cd524
commit 80ac5fb2ec
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 16 additions and 10 deletions

View file

@ -258,13 +258,20 @@ CURLcode Curl_close(struct Curl_easy **datap)
Curl_expire_clear(data); /* shut off any timers left */
data->magic = 0; /* force a clear AFTER the possibly enforced removal from
the multi handle, since that function uses the magic
field! */
if(data->state.rangestringalloc)
free(data->state.range);
/* release any resolve information this transfer kept */
Curl_async_destroy(data);
Curl_resolv_unlink(data, &data->state.dns[0]); /* done with this */
Curl_resolv_unlink(data, &data->state.dns[1]);
data->set.verbose = FALSE; /* no more calls to DEBUGFUNCTION */
data->magic = 0; /* force a clear AFTER the possibly enforced removal from
* the multi handle and async dns shutdown. The multi
* handle might check the magic and so might any
* DEBUGFUNCTION invoked for tracing */
/* freed here just in case DONE was not called */
Curl_req_free(&data->req, data);
@ -299,11 +306,6 @@ CURLcode Curl_close(struct Curl_easy **datap)
Curl_safefree(data->info.contenttype);
Curl_safefree(data->info.wouldredirect);
/* release any resolve information this transfer kept */
Curl_async_destroy(data);
Curl_resolv_unlink(data, &data->state.dns[0]); /* done with this */
Curl_resolv_unlink(data, &data->state.dns[1]);
data_priority_cleanup(data);
/* No longer a dirty share, if it exists */