]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-ssl-iostream: test-iostream-ssl - Plug memory leak
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 29 Jul 2019 13:24:49 +0000 (16:24 +0300)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Tue, 10 Sep 2019 07:02:07 +0000 (10:02 +0300)
If either endpoint fails to initialize it needs to be deinitialized too.

src/lib-ssl-iostream/test-iostream-ssl.c

index 69511cbf166b725951fa17f6367b6fd35818c1aa..2a96280e3ad7fe9cb45a0202ef07a11fa9930358 100644 (file)
@@ -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;
        }