]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/slapi/slapi_pblock.c
Remember to NULL terminate control arrays - not sure how I managed to
[openldap] / servers / slapd / slapi / slapi_pblock.c
index 077dac1cc800bd10645abf8dbc0b28aea93de371..cc1b653e76c7f1ad9a4534af4daee43f0a2209b0 100644 (file)
@@ -762,7 +762,8 @@ pblock_add_control( Slapi_PBlock *pb, LDAPControl *control )
 
        controls = (LDAPControl **)slapi_ch_realloc( (char *)controls,
                ( i + 2 ) * sizeof(LDAPControl *));
-       controls[i] = control;
+       controls[i++] = slapi_dup_control( control );
+       controls[i] = NULL;
 
        return pblock_set_default( pb, SLAPI_RESCONTROLS, (void *)controls );
 }
@@ -818,7 +819,7 @@ pblock_set( Slapi_PBlock *pb, int param, void *value )
                LDAPControl **ctrls = NULL;
 
                pblock_get_default( pb, param, (void **)&ctrls );
-               if ( ctrls == NULL ) {
+               if ( ctrls != NULL ) {
                        /* free old ones first */
                        ldap_controls_free( ctrls );
                }