]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
curl_ws_recv: return recv 0 and point meta to NULL on all errors
authorDaniel Stenberg <daniel@haxx.se>
Sun, 20 Oct 2024 20:29:08 +0000 (22:29 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 20 Oct 2024 20:57:24 +0000 (22:57 +0200)
Previously it could accidentally return some errors without having reset
the values.

Closes #15342

lib/ws.c

index bfdab3af0a2aeaf443947be5821416ac17ee78e6..3d739a538a1742615e543366593f6746dd997074 100644 (file)
--- a/lib/ws.c
+++ b/lib/ws.c
@@ -933,6 +933,9 @@ CURL_EXTERN CURLcode curl_ws_recv(CURL *d, void *buffer,
   struct websocket *ws;
   struct ws_collect ctx;
 
+  *nread = 0;
+  *metap = NULL;
+
   if(!conn) {
     /* Unhappy hack with lifetimes of transfers and connection */
     if(!data->set.connect_only) {
@@ -952,8 +955,6 @@ CURL_EXTERN CURLcode curl_ws_recv(CURL *d, void *buffer,
     return CURLE_BAD_FUNCTION_ARGUMENT;
   }
 
-  *nread = 0;
-  *metap = NULL;
 
   memset(&ctx, 0, sizeof(ctx));
   ctx.data = data;