Fix memory leak when using PSK session files
authorMatt Caswell <matt@openssl.org>
Wed, 5 Jul 2017 09:32:33 +0000 (10:32 +0100)
committerMatt Caswell <matt@openssl.org>
Fri, 7 Jul 2017 09:44:11 +0000 (10:44 +0100)
We were not freeing the session created when loading a PSK session file.

Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
(Merged from https://github.com/openssl/openssl/pull/3855)

apps/s_client.c
apps/s_server.c

index 56209ac0f648de0053b8bbc473918c623b85efc8..5525b3176948e6a4579bef3c3a5d771640b5c302 100644 (file)
@@ -3009,6 +3009,7 @@ int s_client_main(int argc, char **argv)
             print_stuff(bio_c_out, con, 1);
         SSL_free(con);
     }
+    SSL_SESSION_free(psksess);
 #if !defined(OPENSSL_NO_NEXTPROTONEG)
     OPENSSL_free(next_proto.data);
 #endif
index 13cc7a190adae7608d0ad01b55035f7dd459b1cc..8df767c99242c36e2c01d4188849ceb2b12bcd6d 100644 (file)
@@ -2104,6 +2104,7 @@ int s_server_main(int argc, char *argv[])
     ret = 0;
  end:
     SSL_CTX_free(ctx);
+    SSL_SESSION_free(psksess);
     set_keylog_file(NULL, NULL);
     X509_free(s_cert);
     sk_X509_CRL_pop_free(crls, X509_CRL_free);