From 3793761a3777095d643e9f2da951615e1178782c Mon Sep 17 00:00:00 2001
From: Michael Kaufmann <mail@michael-kaufmann.ch>
Date: Thu, 25 Oct 2018 13:07:03 +0200
Subject: [PATCH 216/557] multi: Fix error handling in the SENDPROTOCONNECT
 state

If Curl_protocol_connect() returns an error code,
handle the error instead of switching to the next state.

Closes #3170
---
 lib/multi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/multi.c b/lib/multi.c
index 7c691a1..0db2a97 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -1608,7 +1608,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
 
     case CURLM_STATE_SENDPROTOCONNECT:
       result = Curl_protocol_connect(data->easy_conn, &protocol_connect);
-      if(!protocol_connect)
+      if(!result && !protocol_connect)
         /* switch to waiting state */
         multistate(data, CURLM_STATE_PROTOCONNECT);
       else if(!result) {
-- 
1.8.3.1

