diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-05-25 17:55:16 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-05-25 17:55:16 +0200 |
commit | 494e1a24ec1029fab7d25e8c9bfedfe167a25a64 (patch) | |
tree | 4a931810f047398b2b67b113af6cf0c58bc7b5f2 | |
parent | 54d122287c878188c5bbd4a659295f4ba27e137c (diff) | |
download | curl-bagder/ngtcp2-connectfail-memleak.tar.gz |
ngtcp2: cleanup memory when failing to connectbagder/ngtcp2-connectfail-memleak
Addresses the ngtcp2 side of #5447
-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, |