]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
multi: fix return code for an already-removed easy handle
authorJay Satiro <raysatiro@yahoo.com>
Sat, 28 Dec 2024 23:47:45 +0000 (18:47 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Tue, 31 Dec 2024 08:20:36 +0000 (03:20 -0500)
- 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

lib/multi.c

index 94e64478cd1d5588aa9a8dc30e0d31f64775efc9..7f5a732bff87564577008649170fa18515ceb605 100644 (file)
@@ -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;