From: Daniel Gustafsson Date: Mon, 16 May 2022 19:18:46 +0000 (+0200) Subject: transfer: Fix potential NULL pointer dereference X-Git-Tag: curl-7_84_0~184 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=542c78dda7ff41d9ca6865d705db996fa8ffaf83;p=thirdparty%2Fcurl.git transfer: Fix potential NULL pointer dereference 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 --- diff --git a/lib/transfer.c b/lib/transfer.c index b76e39a68e..49c9fd62bd 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -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 ?