summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-05-25 17:24:36 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-05-26 10:15:18 +0200
commit3ff207f7e34b79fb58759b063d841dbeb383c7c7 (patch)
tree805e057a1552ced42f83ce38928e27f6c6bf2b07
parentd23cc224e6d25eec99a988f4db18c040bde3e97b (diff)
downloadcurl-3ff207f7e34b79fb58759b063d841dbeb383c7c7.tar.gz
quiche: clean up memory properly when failing to connect
Addresses the quiche side of #5447 Reported-by: Peter Wu Closes #5450
-rw-r--r--lib/vquic/quiche.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/vquic/quiche.c b/lib/vquic/quiche.c
index 45c39925f..83815e037 100644
--- a/lib/vquic/quiche.c
+++ b/lib/vquic/quiche.c
@@ -89,18 +89,24 @@ static int quiche_perform_getsock(const struct connectdata *conn,
return quiche_getsock((struct connectdata *)conn, socks);
}
-static CURLcode quiche_disconnect(struct connectdata *conn,
- bool dead_connection)
+static CURLcode qs_disconnect(struct quicsocket *qs)
{
- struct quicsocket *qs = conn->quic;
- (void)dead_connection;
- quiche_h3_config_free(qs->h3config);
- quiche_h3_conn_free(qs->h3c);
+ if(qs->h3config)
+ quiche_h3_config_free(qs->h3config);
+ if(qs->h3c)
+ quiche_h3_conn_free(qs->h3c);
quiche_config_free(qs->cfg);
quiche_conn_free(qs->conn);
return CURLE_OK;
}
+static CURLcode quiche_disconnect(struct connectdata *conn,
+ bool dead_connection)
+{
+ struct quicsocket *qs = conn->quic;
+ (void)dead_connection;
+ return qs_disconnect(qs);
+}
static unsigned int quiche_conncheck(struct connectdata *conn,
unsigned int checks_to_perform)
{
@@ -284,11 +290,11 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn, int sockindex,
result = process_ingress(conn, sockfd, qs);
if(result)
- return result;
+ goto error;
result = flush_egress(conn, sockfd, qs);
if(result)
- return result;
+ goto error;
if(quiche_conn_is_established(qs->conn)) {
*done = TRUE;
@@ -297,6 +303,9 @@ CURLcode Curl_quic_is_connected(struct connectdata *conn, int sockindex,
}
return result;
+ error:
+ qs_disconnect(qs);
+ return result;
}
static CURLcode process_ingress(struct connectdata *conn, int sockfd,