From 6c81656a9538b09623dbddd09c753891ffa010a0 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sun, 29 Jul 2001 17:21:28 +0000 Subject: [PATCH] fixed some memory allocation nonsense --- servers/slapd/limits.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/servers/slapd/limits.c b/servers/slapd/limits.c index 2b4829a319..ef6ccc9da6 100644 --- a/servers/slapd/limits.c +++ b/servers/slapd/limits.c @@ -23,6 +23,10 @@ get_limits( { struct slap_limits **lm; + assert( be ); + assert( timelimit ); + assert( sizelimit ); + /* * default values */ @@ -106,16 +110,15 @@ add_limits( lm->lm_timelimit = timelimit; lm->lm_sizelimit = sizelimit; - if ( be->be_limits == NULL ) { - i = 1; - be->be_limits = ( struct slap_limits ** )ch_calloc( sizeof( struct slap_limits * ), 2 ); - } else { - for ( i = 0; be->be_limits[i]; i++ ); - - be->be_limits = ( struct slap_limits ** )ch_realloc( be->be_limits, - sizeof( struct slap_limits * ) * ( i + 1 ) ); + i = 0; + if ( be->be_limits != NULL ) { + for ( ; be->be_limits[i]; i++ ); } + + be->be_limits = ( struct slap_limits ** )ch_realloc( be->be_limits, + sizeof( struct slap_limits * ) * ( i + 2 ) ); be->be_limits[i] = lm; + be->be_limits[i+1] = NULL; return( 0 ); } -- 2.39.5