From 593512bb7b2b5d23a658d3a8d05bdeeb15d7611f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kuzn=C3=ADk?= Date: Wed, 27 Mar 2019 10:26:44 +0000 Subject: [PATCH] Do not leak lds in slapd-* tools --- tests/progs/slapd-bind.c | 3 +++ tests/progs/slapd-common.c | 3 ++- tests/progs/slapd-modify.c | 4 +++- tests/progs/slapd-modrdn.c | 4 +++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/progs/slapd-bind.c b/tests/progs/slapd-bind.c index a275212ac7..3f977a3553 100644 --- a/tests/progs/slapd-bind.c +++ b/tests/progs/slapd-bind.c @@ -469,6 +469,9 @@ novals:; if ( ndns == 0 ) { tester_error( "No DNs" ); + if ( ld != NULL ) { + ldap_unbind_ext( ld, NULL, NULL ); + } return 1; } diff --git a/tests/progs/slapd-common.c b/tests/progs/slapd-common.c index a919a55e9b..ceda3b74f0 100644 --- a/tests/progs/slapd-common.c +++ b/tests/progs/slapd-common.c @@ -518,6 +518,7 @@ retry:; if ( rc != LDAP_OPT_SUCCESS ) { tester_ldap_error( ld, "ldap_set_option(SECPROPS)", NULL ); + ldap_unbind_ext( ld, NULL, NULL ); exit( EXIT_FAILURE ); } } @@ -552,7 +553,7 @@ retry:; goto retry; } } - tester_ldap_error( ld, "ldap_sasl_bind_s", NULL ); + ldap_unbind_ext( ld, NULL, NULL ); exit( EXIT_FAILURE ); } } diff --git a/tests/progs/slapd-modify.c b/tests/progs/slapd-modify.c index 7ea408003b..f8df6b4e00 100644 --- a/tests/progs/slapd-modify.c +++ b/tests/progs/slapd-modify.c @@ -150,7 +150,9 @@ do_modify( struct tester_conn_args *config, mods[1] = NULL; retry:; - tester_init_ld( &ld, config, 0 ); + if ( ld == NULL ) { + tester_init_ld( &ld, config, 0 ); + } if ( do_retry == config->retries ) { fprintf( stderr, "PID=%ld - Modify(%d): entry=\"%s\".\n", diff --git a/tests/progs/slapd-modrdn.c b/tests/progs/slapd-modrdn.c index 665a44cf7b..4fc339c5a9 100644 --- a/tests/progs/slapd-modrdn.c +++ b/tests/progs/slapd-modrdn.c @@ -144,7 +144,9 @@ do_modrdn( struct tester_conn_args *config, i = 0; retry:; - tester_init_ld( &ld, config, 0 ); + if ( ld == NULL ) { + tester_init_ld( &ld, config, 0 ); + } if ( do_retry == config->retries ) { fprintf( stderr, "PID=%ld - Modrdn(%d): entry=\"%s\".\n",