diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-05-25 17:55:16 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-05-26 10:16:32 +0200 |
commit | 96a822f6e2de3df00c94bd74a5981032678da70a (patch) | |
tree | 3849518094dff8defeca874fadab271bea5200cf /lib/vquic | |
parent | 3ff207f7e34b79fb58759b063d841dbeb383c7c7 (diff) |
ngtcp2: cleanup memory when failing to connect
Reported-by: Peter Wu
Fixes #5447 (the ngtcp2 side of it)
Closes #5451
Diffstat (limited to 'lib/vquic')
-rw-r--r-- | lib/vquic/ngtcp2.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/vquic/ngtcp2.c b/lib/vquic/ngtcp2.c index 3ad8d08eb..3b5670616 100644 --- a/lib/vquic/ngtcp2.c +++ b/lib/vquic/ngtcp2.c @@ -906,12 +906,9 @@ static int ng_perform_getsock(const struct connectdata *conn, return ng_getsock((struct connectdata *)conn, socks); } -static CURLcode ng_disconnect(struct connectdata *conn, - bool dead_connection) +static CURLcode qs_disconnect(struct quicsocket *qs) { int i; - struct quicsocket *qs = &conn->hequic[0]; - (void)dead_connection; if(qs->qlogfd != -1) close(qs->qlogfd); if(qs->ssl) @@ -934,6 +931,13 @@ static CURLcode ng_disconnect(struct connectdata *conn, return CURLE_OK; } +static CURLcode ng_disconnect(struct connectdata *conn, + bool dead_connection) +{ + (void)dead_connection; + return qs_disconnect(&conn->hequic[0]); +} + static unsigned int ng_conncheck(struct connectdata *conn, unsigned int checks_to_perform) { @@ -1706,11 +1710,11 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn, result = ng_process_ingress(conn, sockfd, qs); if(result) - return result; + goto error; result = ng_flush_egress(conn, sockfd, qs); if(result) - return result; + goto error; if(ngtcp2_conn_get_handshake_completed(qs->qconn)) { *done = TRUE; @@ -1718,6 +1722,10 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn, } return result; + error: + (void)qs_disconnect(qs); + return result; + } static CURLcode ng_process_ingress(struct connectdata *conn, int sockfd, |