From: BANADDA Date: Sat, 15 Nov 2025 02:08:10 +0000 (+0000) Subject: examples/multi-uv: fix invalid req->data access X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c722346518365c401b572f8dbe5fa6792ba923cd;p=thirdparty%2Fcurl.git examples/multi-uv: fix invalid req->data access The on_uv_timeout callback was trying to access req->data as a curl_context pointer, but uv.timeout.data was never initialized, making it always NULL. This rendered the code inside the if(context) block unreachable. Fixes #19462 Closes #19538 --- diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c index 190bed3ef4..75fec20199 100644 --- a/docs/examples/multi-uv.c +++ b/docs/examples/multi-uv.c @@ -160,12 +160,19 @@ static void on_uv_socket(uv_poll_t *req, int status, int events) /* callback from libuv when timeout expires */ static void on_uv_timeout(uv_timer_t *req) { - struct curl_context *context = (struct curl_context *) req->data; - if(context) { - int running_handles; - curl_multi_socket_action(context->uv->multi, CURL_SOCKET_TIMEOUT, 0, - &running_handles); - check_multi_info(context); + /* get the datauv struct from the timer handle */ + struct datauv *uv = (struct datauv *)req; + int running_handles; + + curl_multi_socket_action(uv->multi, CURL_SOCKET_TIMEOUT, 0, + &running_handles); + + /* We do not have a curl_context here, so we need to check messages + differently. Create a temporary context just for the check. */ + if(running_handles) { + struct curl_context temp_context; + temp_context.uv = uv; + check_multi_info(&temp_context); } }