]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ws: avoid NULL pointer deref in curl_ws_recv
authorDaniel Stenberg <daniel@haxx.se>
Mon, 28 Jul 2025 13:54:59 +0000 (15:54 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 28 Jul 2025 20:37:59 +0000 (22:37 +0200)
If a NULL easy handle is passed in.

Pointed out by Coverity

Follow-up to 960fb4924523a853d5de8f30

Closes #18065

lib/ws.c

index 829ccfc822308915c3fa8e1e86d22303334551c8..ac542fbc14901bed559712d7e7fbb10d04af9a3d 100644 (file)
--- 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) {