From 9dd86298db9fdceb87725af9e409de7f0afd60c4 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Thu, 5 Jun 2008 22:37:00 +0200 Subject: [PATCH] Fix memory leaks. --- tests/dhepskself.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tests/dhepskself.c b/tests/dhepskself.c index 73c901afe..48dfe843b 100644 --- a/tests/dhepskself.c +++ b/tests/dhepskself.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005 Free Software Foundation + * Copyright (C) 2004, 2005, 2008 Free Software Foundation * * Author: Simon Josefsson * @@ -241,19 +241,6 @@ int optval = 1; void server_start (void) { - /* this must be called once in the program - */ - gnutls_global_init (); - - gnutls_global_set_log_function (tls_log_func); -// gnutls_global_set_log_level (99); - - generate_dh_params (); - - gnutls_psk_allocate_server_credentials (&server_pskcred); - gnutls_psk_set_server_credentials_function (server_pskcred, pskfunc); - gnutls_psk_set_server_dh_params (server_pskcred, dh_params); - success ("Launched, generating DH parameters...\n"); /* Socket operations @@ -295,6 +282,19 @@ server_start (void) void server (void) { + /* this must be called once in the program + */ + gnutls_global_init (); + + gnutls_global_set_log_function (tls_log_func); + // gnutls_global_set_log_level (99); + + generate_dh_params (); + + gnutls_psk_allocate_server_credentials (&server_pskcred); + gnutls_psk_set_server_credentials_function (server_pskcred, pskfunc); + gnutls_psk_set_server_dh_params (server_pskcred, dh_params); + client_len = sizeof (sa_cli); session = initialize_tls_session (); @@ -353,6 +353,8 @@ server (void) gnutls_psk_free_server_credentials (server_pskcred); + gnutls_dh_params_deinit (dh_params); + gnutls_global_deinit (); success ("server: finished\n"); -- 2.11.4.GIT