From 9d2075bdce1234360bd41a9146ab9b465750a840 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 28 Jul 2025 15:54:59 +0200 Subject: [PATCH] ws: avoid NULL pointer deref in curl_ws_recv If a NULL easy handle is passed in. Pointed out by Coverity Follow-up to 960fb4924523a853d5de8f30 Closes #18065 --- lib/ws.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ws.c b/lib/ws.c index 829ccfc822..ac542fbc14 100644 --- a/lib/ws.c +++ b/lib/ws.c @@ -1150,7 +1150,7 @@ CURLcode curl_ws_recv(CURL *d, void *buffer, const struct curl_ws_frame **metap) { struct Curl_easy *data = d; - struct connectdata *conn = data->conn; + struct connectdata *conn; struct websocket *ws; struct ws_collect ctx; @@ -1159,6 +1159,7 @@ CURLcode curl_ws_recv(CURL *d, void *buffer, if(!GOOD_EASY_HANDLE(data)) return CURLE_BAD_FUNCTION_ARGUMENT; + conn = data->conn; if(!conn) { /* Unhappy hack with lifetimes of transfers and connection */ if(!data->set.connect_only) {