From: Howard Chu Date: Tue, 2 Mar 2004 20:31:37 +0000 (+0000) Subject: Fix SLAPI_ADD_RESCONTROLS X-Git-Tag: OPENLDAP_REL_ENG_2_2_BP~385 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1b98cd6262e5a9b9a842059b37c0c9a7429dbbb4;p=openldap Fix SLAPI_ADD_RESCONTROLS --- diff --git a/servers/slapd/slapi/slapi_pblock.c b/servers/slapd/slapi/slapi_pblock.c index da0a017d93..503c2c0149 100644 --- a/servers/slapd/slapi/slapi_pblock.c +++ b/servers/slapd/slapi/slapi_pblock.c @@ -321,8 +321,13 @@ set( Slapi_PBlock *pb, int param, void *val ) LDAPControl **ctrls = pb->curVals[i]; int j; - for (j=0; ctrls[j]; j++); - ctrls = ch_realloc( ctrls, (j+2)*sizeof(LDAPControl *) ); + if ( ctrls ) { + for (j=0; ctrls[j]; j++); + ctrls = ch_realloc( ctrls, (j+2)*sizeof(LDAPControl *) ); + } else { + ctrls = ch_malloc( 2 * sizeof(LDAPControl *) ); + j = 0; + } ctrls[j] = val; ctrls[j+1] = NULL; pb->curVals[i] = ctrls;