From: Aki Tuomi Date: Mon, 29 Jul 2019 13:24:49 +0000 (+0300) Subject: lib-ssl-iostream: test-iostream-ssl - Plug memory leak X-Git-Tag: 2.3.9~351 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5977e925b967a1e880c8463272c81405262d5e83;p=thirdparty%2Fdovecot%2Fcore.git lib-ssl-iostream: test-iostream-ssl - Plug memory leak If either endpoint fails to initialize it needs to be deinitialized too. --- diff --git a/src/lib-ssl-iostream/test-iostream-ssl.c b/src/lib-ssl-iostream/test-iostream-ssl.c index 69511cbf16..2a96280e3a 100644 --- a/src/lib-ssl-iostream/test-iostream-ssl.c +++ b/src/lib-ssl-iostream/test-iostream-ssl.c @@ -144,7 +144,8 @@ static void destroy_test_endpoint(struct test_endpoint **_ep) o_stream_unref(&ep->output); ssl_iostream_destroy(&ep->iostream); i_close_fd(&ep->fd); - ssl_iostream_context_unref(&ep->ctx); + if (ep->ctx != NULL) + ssl_iostream_context_unref(&ep->ctx); pool_unref(&ep->pool); } @@ -170,11 +171,15 @@ static int test_iostream_ssl_handshake_real(struct ssl_iostream_settings *server if (ssl_iostream_context_init_server(server->set, &server->ctx, &error) < 0) { i_error("server: %s", error); + destroy_test_endpoint(&client); + destroy_test_endpoint(&server); return -1; } if (ssl_iostream_context_init_client(client->set, &client->ctx, &error) < 0) { i_error("client: %s", error); + destroy_test_endpoint(&client); + destroy_test_endpoint(&server); return -1; }