From f69306c84a9aed281c3a14790a4af13f6cb8760c Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Fri, 17 Aug 2007 14:41:32 +0000 Subject: [PATCH] fix previous commit (may be called more than once) --- clients/tools/common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clients/tools/common.c b/clients/tools/common.c index 2e571ced09..78d8db7811 100644 --- a/clients/tools/common.c +++ b/clients/tools/common.c @@ -537,9 +537,10 @@ tool_args( int argc, char **argv ) } tmpctrls = (LDAPControl *)realloc( unknown_ctrls, - (unknown_ctrls_num + 2)*sizeof( LDAPControl ) ); + (unknown_ctrls_num + 1)*sizeof( LDAPControl ) ); if ( tmpctrls == NULL ) { - + fprintf( stderr, "%s: no memory?\n", prog ); + exit( EXIT_FAILURE ); } unknown_ctrls = tmpctrls; ctrl.ldctl_oid = control; @@ -1594,8 +1595,7 @@ tool_server_controls( LDAP *ld, LDAPControl *extra_c, int count ) while ( count-- ) { ctrls[i++] = extra_c++; } - count = 0; - while ( unknown_ctrls_num-- ) { + for ( count = 0; count < unknown_ctrls_num; count++ ) { ctrls[i++] = &unknown_ctrls[count++]; } ctrls[i] = NULL; -- 2.39.5