From: Howard Chu Date: Wed, 28 May 2003 22:17:08 +0000 (+0000) Subject: Fix LBER_OPT_MEMCTX behavior X-Git-Tag: OPENLDAP_REL_ENG_2_2_0ALPHA~24 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5d0ba372e56dcab4298c16d9ca8273e6fd3973ba;p=openldap Fix LBER_OPT_MEMCTX behavior --- diff --git a/libraries/liblber/options.c b/libraries/liblber/options.c index e5d48f0538..f59dcc1393 100644 --- a/libraries/liblber/options.c +++ b/libraries/liblber/options.c @@ -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: diff --git a/servers/slapd/connection.c b/servers/slapd/connection.c index 1c5281e340..9d10555416 100644 --- a/servers/slapd/connection.c +++ b/servers/slapd/connection.c @@ -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: diff --git a/servers/slapd/operation.c b/servers/slapd/operation.c index 537263b7d5..95e28288b5 100644 --- a/servers/slapd/operation.c +++ b/servers/slapd/operation.c @@ -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 ) { diff --git a/servers/slapd/result.c b/servers/slapd/result.c index 41e5eed0f0..0e0899fae3 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -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, diff --git a/servers/slapd/str2filter.c b/servers/slapd/str2filter.c index c4f41060d9..310c3a56c9 100644 --- a/servers/slapd/str2filter.c +++ b/servers/slapd/str2filter.c @@ -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 ); diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 4c0629a9a9..75de5dd58d 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -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 );