]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
transfer: Fix potential NULL pointer dereference
authorDaniel Gustafsson <daniel@yesql.se>
Mon, 16 May 2022 19:18:46 +0000 (21:18 +0200)
committerDaniel Gustafsson <daniel@yesql.se>
Mon, 16 May 2022 19:18:46 +0000 (21:18 +0200)
Commit 0ef54abf5208 accidentally used the conn variable before the
assertion for it being NULL. Fix by moving the assignment which use
conn to after the assertion.

Closes: #8857
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
lib/transfer.c

index b76e39a68efcdc7a8a5c9c5b4415f27de6e26759..49c9fd62bd409bc4440cd43e428ae6ef0f7b4a20 100644 (file)
@@ -1896,11 +1896,14 @@ Curl_setup_transfer(
   struct SingleRequest *k = &data->req;
   struct connectdata *conn = data->conn;
   struct HTTP *http = data->req.p.http;
-  bool httpsending = ((conn->handler->protocol&PROTO_FAMILY_HTTP) &&
-                      (http->sending == HTTPSEND_REQUEST));
+  bool httpsending;
+
   DEBUGASSERT(conn != NULL);
   DEBUGASSERT((sockindex <= 1) && (sockindex >= -1));
 
+  httpsending = ((conn->handler->protocol&PROTO_FAMILY_HTTP) &&
+                 (http->sending == HTTPSEND_REQUEST));
+
   if(conn->bits.multiplex || conn->httpversion == 20 || httpsending) {
     /* when multiplexing, the read/write sockets need to be the same! */
     conn->sockfd = sockindex == -1 ?