From: Jay Satiro Date: Sat, 28 Dec 2024 23:47:45 +0000 (-0500) Subject: multi: fix return code for an already-removed easy handle X-Git-Tag: curl-8_12_0~237 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=713182bd196bba014ba77f71176fea3de2236724;p=thirdparty%2Fcurl.git multi: fix return code for an already-removed easy handle - Ensure that CURLM_OK is returned when curl_multi_remove_handle is called with an already removed easy handle. Prior to this change and since ba235ab2 which precedes 8.10.0, if curl_multi_remove_handle was called with an already-removed easy handle then the return code would be CURLM_OK or CURLM_BAD_EASY_HANDLE depending respectively on whether the multi did or did not contain other easy handles. This change restores the old behavior of returning CURLM_OK in both cases. Reported-by: Ralph Sennhauser Fixes https://github.com/curl/curl/issues/15844 Closes https://github.com/curl/curl/pull/15852 --- diff --git a/lib/multi.c b/lib/multi.c index 94e64478cd..7f5a732bff 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -787,7 +787,7 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d) return CURLM_BAD_HANDLE; /* Verify that we got a somewhat good easy handle too */ - if(!GOOD_EASY_HANDLE(data) || !multi->num_easy) + if(!GOOD_EASY_HANDLE(data)) return CURLM_BAD_EASY_HANDLE; /* Prevent users from trying to remove same easy handle more than once */ @@ -798,6 +798,11 @@ CURLMcode curl_multi_remove_handle(CURLM *m, CURL *d) if(data->multi != multi) return CURLM_BAD_EASY_HANDLE; + if(!multi->num_easy) { + DEBUGASSERT(0); + return CURLM_INTERNAL_ERROR; + } + if(multi->in_callback) return CURLM_RECURSIVE_API_CALL;