From: Luke Howard Date: Fri, 22 Jul 2005 08:26:20 +0000 (+0000) Subject: Fix bug in control merging (this probably still isn't right...) X-Git-Tag: OPENLDAP_AC_BP~253 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3e47ba5aef459b00c35988493c372a46196698bf;p=openldap Fix bug in control merging (this probably still isn't right...) --- diff --git a/servers/slapd/slapi/slapi_overlay.c b/servers/slapd/slapi/slapi_overlay.c index 0f54ef80ca..51b7bdc0d5 100644 --- a/servers/slapd/slapi/slapi_overlay.c +++ b/servers/slapd/slapi/slapi_overlay.c @@ -174,7 +174,7 @@ slapi_over_count_controls( LDAPControl **controls ) int i; if ( controls == NULL ) - return i; + return 0; for ( i = 0; controls[i] != NULL; i++ ) ; @@ -191,16 +191,16 @@ slapi_over_merge_controls( Operation *op, SlapReply *rs ) int nResControls = 0; int i; - nResControls = slapi_over_count_controls( rs->sr_ctrls ); - slapi_pblock_get( pb, SLAPI_RESCONTROLS, (void **)&slapiControls ); nSlapiControls = slapi_over_count_controls( slapiControls ); - if ( nResControls + nSlapiControls == 0 ) { + if ( nSlapiControls == 0 ) { /* short-circuit */ return LDAP_SUCCESS; } + nResControls = slapi_over_count_controls( rs->sr_ctrls ); + /* XXX this is a bit tricky, rs->sr_ctrls may have been allocated on stack */ mergedControls = (LDAPControl **)op->o_tmpalloc( ( nResControls + nSlapiControls + 1 ) * sizeof( LDAPControl *), op->o_tmpmemctx );