]> git.sur5r.net Git - openldap/commitdiff
Fix LBER_OPT_MEMCTX behavior
authorHoward Chu <hyc@openldap.org>
Wed, 28 May 2003 22:17:08 +0000 (22:17 +0000)
committerHoward Chu <hyc@openldap.org>
Wed, 28 May 2003 22:17:08 +0000 (22:17 +0000)
libraries/liblber/options.c
servers/slapd/connection.c
servers/slapd/operation.c
servers/slapd/result.c
servers/slapd/str2filter.c
servers/slapd/syncrepl.c

index e5d48f0538d6f374f632cb3998ebb1cc29a0dba7..f59dcc13935a8179a1ceb332d3cd5013b31d5104 100644 (file)
@@ -211,7 +211,7 @@ ber_set_option(
 
        case LBER_OPT_BER_MEMCTX:
                assert( LBER_VALID( ber ) );
-               ber->ber_memctx = (void *)invalue;
+               ber->ber_memctx = *(void **)invalue;
                return LBER_OPT_SUCCESS;
 
        default:
index 1c5281e34064fea235c35fb600c869c0ee404c54..9d105554168eff5ce503ca677d6020830307526b 100644 (file)
@@ -934,7 +934,7 @@ connection_operation( void *ctx, void *arg_v )
                 * regular memory; this only affects subsequent mallocs that
                 * ber_scanf may invoke.
                 */
-               ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, memctx );
+               ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, &memctx );
        }
 
        switch ( tag ) {
@@ -1088,7 +1088,8 @@ operations_error:
 
 co_op_free:
 
-       ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, NULL );
+       memctx = NULL;
+       ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, &memctx );
        slap_op_free( op );
 
 no_co_op_free:
index 537263b7d54c0a98b9c6600397bd4099aea20646..95e28288b5882ab35f5b0b1596b94d8f410d9107 100644 (file)
@@ -45,10 +45,6 @@ slap_op_free( Operation *op )
        assert( LDAP_STAILQ_NEXT(op, o_next) == NULL );
 
        if ( op->o_ber != NULL ) {
-               /* Note - the ber and its buffer are in regular memory,
-                * so make sure not to use sl_free here.
-                */
-               ber_set_option( op->o_ber, LBER_OPT_BER_MEMCTX, NULL );
                ber_free( op->o_ber, 1 );
        }
        if ( op->o_dn.bv_val != NULL ) {
index 41e5eed0f0ecbd7f1ee8de9ec5ac7ba66201dc55..0e0899fae39d83291c7c28ed45f03e996fcb8afb 100644 (file)
@@ -240,7 +240,7 @@ send_ldap_response(
 #endif
        {
                ber_init_w_nullc( ber, LBER_USE_DER );
-               ber_set_option( ber, LBER_OPT_BER_MEMCTX, op->o_tmpmemctx );
+               ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
        }
 
 #ifdef NEW_LOGGING
@@ -649,7 +649,7 @@ slap_send_search_entry( Operation *op, SlapReply *rs )
                bv.bv_val = op->o_tmpalloc(bv.bv_len, op->o_tmpmemctx );
 
                ber_init2( ber, &bv, LBER_USE_DER );
-               ber_set_option( ber, LBER_OPT_BER_MEMCTX, op->o_tmpmemctx );
+               ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
        }
 
 #ifdef LDAP_CONNECTIONLESS
@@ -1297,7 +1297,7 @@ slap_send_search_reference( Operation *op, SlapReply *rs )
 #endif
        {
                ber_init_w_nullc( ber, LBER_USE_DER );
-               ber_set_option( ber, LBER_OPT_BER_MEMCTX, op->o_tmpmemctx );
+               ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
        }
 
        rc = ber_printf( ber, "{it{W}" /*"}"*/ , op->o_msgid,
index c4f41060d9cbe2ef5f8c5a61ff0faf164108b81c..310c3a56c90db9d92fbccaaea558c5118d3c6c21 100644 (file)
@@ -44,7 +44,7 @@ str2filter_x( Operation *op, const char *str )
 
        ber_init2( ber, NULL, LBER_USE_DER );
        if ( op->o_tmpmemctx ) {
-               ber_set_option( ber, LBER_OPT_BER_MEMCTX, op->o_tmpmemctx );
+               ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
        }
 
        rc = ldap_pvt_put_filter( ber, str );
index 4c0629a9a9fb0311c9dd21a6967e5cdbd3e39a39..75de5dd58d83d415684e943c4ac5ebd844eb2210 100644 (file)
@@ -386,7 +386,7 @@ do_syncrepl(
 
        /* setup LDAP SYNC control */
        sync_ber = ber_alloc_t( LBER_USE_DER );
-       ber_set_option( sync_ber, LBER_OPT_BER_MEMCTX, op.o_tmpmemctx );
+       ber_set_option( sync_ber, LBER_OPT_BER_MEMCTX, &op.o_tmpmemctx );
 
        if ( si->syncCookie ) {
                ber_printf( sync_ber, "{eO}", abs(si->type), si->syncCookie );
@@ -520,7 +520,7 @@ do_syncrepl(
                                if ( rctrls ) {
                                        rctrlp = *rctrls;
                                        ctrl_ber = ber_alloc_t( LBER_USE_DER );
-                                       ber_set_option( ctrl_ber, LBER_OPT_BER_MEMCTX, op.o_tmpmemctx );
+                                       ber_set_option( ctrl_ber, LBER_OPT_BER_MEMCTX, &op.o_tmpmemctx );
                                        ber_write( ctrl_ber, rctrlp->ldctl_value.bv_val, rctrlp->ldctl_value.bv_len, 0 );
                                        ber_reset( ctrl_ber, 1 );
 
@@ -787,7 +787,7 @@ syncrepl_message_to_entry(
        if ( rctrls ) {
                rctrlp = *rctrls;
                ctrl_ber = ber_alloc_t( LBER_USE_DER );
-               ber_set_option( ctrl_ber, LBER_OPT_BER_MEMCTX, op->o_tmpmemctx );
+               ber_set_option( ctrl_ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
                ber_write( ctrl_ber, rctrlp->ldctl_value.bv_val, rctrlp->ldctl_value.bv_len, 0 );
                ber_reset( ctrl_ber, 1 );
                ber_scanf( ctrl_ber, "{eo", syncstate, syncUUID );