Fix connection leak in http subtransport
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
diff --git a/src/netops.c b/src/netops.c
index 3e27434..2d079ef 100644
--- a/src/netops.c
+++ b/src/netops.c
@@ -193,16 +193,19 @@ void gitno_consume_n(gitno_buffer *buf, size_t cons)
static int gitno_ssl_teardown(gitno_ssl *ssl)
{
int ret;
-
+
do {
ret = SSL_shutdown(ssl->ssl);
} while (ret == 0);
+
if (ret < 0)
- return ssl_set_error(ssl, ret);
+ ret = ssl_set_error(ssl, ret);
+ else
+ ret = 0;
SSL_free(ssl->ssl);
SSL_CTX_free(ssl->ctx);
- return 0;
+ return ret;
}
/* Match host names according to RFC 2818 rules */
diff --git a/src/transports/http.c b/src/transports/http.c
index 4b48779..f2ff2d6 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -606,6 +606,9 @@ static void http_free(git_smart_subtransport *smart_transport)
clear_parser_state(t);
+ if (t->socket.socket)
+ gitno_close(&t->socket);
+
if (t->cred) {
t->cred->free(t->cred);
t->cred = NULL;