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
This commit is contained in:
BANADDA 2025-11-15 02:08:10 +00:00 committed by Viktor Szakats
parent 2acdc4f549
commit c722346518
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201

View file

@ -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);
}
}