Plug memleaks
authortb <tb@openbsd.org>
Wed, 29 Dec 2021 23:04:12 +0000 (23:04 +0000)
committertb <tb@openbsd.org>
Wed, 29 Dec 2021 23:04:12 +0000 (23:04 +0000)
CID 345150

regress/lib/libssl/unit/ssl_versions.c

index 2ca7215..62ecc78 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssl_versions.c,v 1.15 2021/06/27 16:54:55 jsing Exp $ */
+/* $OpenBSD: ssl_versions.c,v 1.16 2021/12/29 23:04:12 tb Exp $ */
 /*
  * Copyright (c) 2016, 2017 Joel Sing <jsing@openbsd.org>
  *
@@ -502,11 +502,13 @@ test_ssl_max_shared_version(void)
 
                if ((ssl_ctx = SSL_CTX_new(svt->ssl_method())) == NULL) {
                        fprintf(stderr, "SSL_CTX_new() returned NULL\n");
-                       return 1;
+                       failed++;
+                       goto err;
                }
                if ((ssl = SSL_new(ssl_ctx)) == NULL) {
                        fprintf(stderr, "SSL_new() returned NULL\n");
-                       return 1;
+                       failed++;
+                       goto err;
                }
 
                SSL_clear_options(ssl, SSL_OP_NO_TLSv1 | SSL_OP_NO_TLSv1_1 |
@@ -535,8 +537,14 @@ test_ssl_max_shared_version(void)
 
                SSL_CTX_free(ssl_ctx);
                SSL_free(ssl);
+               ssl_ctx = NULL;
+               ssl = NULL;
        }
 
+ err:
+       SSL_CTX_free(ssl_ctx);
+       SSL_free(ssl);
+
        return (failed);
 }