diff --git a/lib/ftp.c b/lib/ftp.c index ae2c90965d..e6e9821c9c 100644 --- a/lib/ftp.c +++ b/lib/ftp.c @@ -3565,8 +3565,10 @@ static CURLcode ftp_do_more(struct Curl_easy *data, int *completep) bool connected = FALSE; bool complete = FALSE; - /* the ftp struct is inited in ftp_connect() */ - struct FTP *ftp = data->req.p.ftp; + /* the ftp struct is inited in ftp_connect(). If we are connecting to an HTTP + * proxy then the state will not be valid until after that connection is + * complete */ + struct FTP *ftp = NULL; /* if the second connection isn't done yet, wait for it */ if(!conn->bits.tcpconnect[SECONDARYSOCKET]) { @@ -3607,6 +3609,9 @@ static CURLcode ftp_do_more(struct Curl_easy *data, int *completep) return result; #endif + /* Curl_proxy_connect might have moved the protocol state */ + ftp = data->req.p.ftp; + if(ftpc->state) { /* already in a state so skip the initial commands. They are only done to kickstart the do_more state */