Commit 28828e1b authored by Ondřej Kuzník's avatar Ondřej Kuzník
Browse files

ITS#9160 OOM handling in contrib

parent af5ed7c6
......@@ -277,10 +277,10 @@ aa_operational( Operation *op, SlapReply *rs )
/* just count */ ;
if ( got & GOT_A ) {
bv_allowed = ber_memalloc( sizeof( struct berval ) * ( i + 1 ) );
bv_allowed = ch_calloc( i + 1, sizeof( struct berval ) );
}
if ( got & GOT_AE ) {
bv_effective = ber_memalloc( sizeof( struct berval ) * ( i + 1 ) );
bv_effective = ch_calloc( i + 1, sizeof( struct berval ) );
}
for ( i = 0, ja = 0, je = 0; atp[ i ] != NULL; i++ ) {
......@@ -310,7 +310,6 @@ aa_operational( Operation *op, SlapReply *rs )
ch_free( atp );
if ( ( got & GOT_A ) && ja > 0 ) {
BER_BVZERO( &bv_allowed[ ja ] );
*ap = attr_alloc( ad_allowedAttributes );
(*ap)->a_vals = bv_allowed;
(*ap)->a_nvals = bv_allowed;
......@@ -319,7 +318,6 @@ aa_operational( Operation *op, SlapReply *rs )
}
if ( ( got & GOT_AE ) && je > 0 ) {
BER_BVZERO( &bv_effective[ je ] );
*ap = attr_alloc( ad_allowedAttributesEffective );
(*ap)->a_vals = bv_effective;
(*ap)->a_nvals = bv_effective;
......@@ -348,10 +346,10 @@ do_oc:;
}
if ( got & GOT_C ) {
bv_allowed = ber_memalloc( sizeof( struct berval ) * ( i + 1 ) );
bv_allowed = ch_calloc( i + 1, sizeof( struct berval ) );
}
if ( got & GOT_CE ) {
bv_effective = ber_memalloc( sizeof( struct berval ) * ( i + 1 ) );
bv_effective = ch_calloc( i + 1, sizeof( struct berval ) );
}
for ( oc_start( &oc ); oc != NULL; oc_next( &oc ) ) {
......@@ -398,7 +396,6 @@ done_ce:;
}
if ( ( got & GOT_C ) && ja > 0 ) {
BER_BVZERO( &bv_allowed[ ja ] );
*ap = attr_alloc( ad_allowedChildClasses );
(*ap)->a_vals = bv_allowed;
(*ap)->a_nvals = bv_allowed;
......@@ -407,7 +404,6 @@ done_ce:;
}
if ( ( got & GOT_CE ) && je > 0 ) {
BER_BVZERO( &bv_effective[ je ] );
*ap = attr_alloc( ad_allowedChildClassesEffective );
(*ap)->a_vals = bv_effective;
(*ap)->a_nvals = bv_effective;
......
......@@ -117,7 +117,7 @@ authzid_conn_insert( Connection *c, char flag )
return -1;
}
ac = SLAP_MALLOC( sizeof( authzid_conn_t ) );
ac = ch_malloc( sizeof( authzid_conn_t ) );
ac->conn = c;
ac->refcnt = 0;
ac->authzid_flag = flag;
......@@ -143,7 +143,7 @@ authzid_conn_remove( Connection *c )
ldap_pvt_thread_mutex_unlock( &authzid_mutex );
assert( tmp == ac );
SLAP_FREE( ac );
ch_free( ac );
return 0;
}
......
......@@ -223,8 +223,8 @@ rdnval_rdn2vals(
/* NOTE: we assume rdn and nrdn contain the same AVAs! */
*valsp = SLAP_CALLOC( sizeof( struct berval ), nAVA + 1 );
*nvalsp = SLAP_CALLOC( sizeof( struct berval ), nAVA + 1 );
*valsp = ch_calloc( sizeof( struct berval ), nAVA + 1 );
*nvalsp = ch_calloc( sizeof( struct berval ), nAVA + 1 );
/* Add new attribute values to the entry */
for ( i = 0; rdn[ i ]; i++ ) {
......@@ -354,7 +354,7 @@ rdnval_op_rename( Operation *op, SlapReply *rs )
send_ldap_result( op, rs );
}
ml = SLAP_CALLOC( sizeof( Modifications ), 1 );
ml = ch_calloc( sizeof( Modifications ), 1 );
ml->sml_values = vals;
ml->sml_nvalues = nvals;
......
......@@ -121,8 +121,8 @@ vernum_op_modify( Operation *op, SlapReply *rs )
/* ITS#6561 */
#ifdef SLAP_MOD_ADD_IF_NOT_PRESENT
/* the initial value is only added if the vernum attr is not present */
ml = SLAP_CALLOC( sizeof( Modifications ), 1 );
ml->sml_values = SLAP_CALLOC( sizeof( struct berval ) , 2 );
ml = ch_calloc( sizeof( Modifications ), 1 );
ml->sml_values = ch_calloc( sizeof( struct berval ) , 2 );
value_add_one( &ml->sml_values, &val_init );
ml->sml_nvalues = NULL;
ml->sml_numvals = 1;
......@@ -136,8 +136,8 @@ vernum_op_modify( Operation *op, SlapReply *rs )
#endif /* SLAP_MOD_ADD_IF_NOT_PRESENT */
/* this increments by 1 the vernum attr */
ml = SLAP_CALLOC( sizeof( Modifications ), 1 );
ml->sml_values = SLAP_CALLOC( sizeof( struct berval ) , 2 );
ml = ch_calloc( sizeof( Modifications ), 1 );
ml->sml_values = ch_calloc( sizeof( struct berval ) , 2 );
value_add_one( &ml->sml_values, &val );
ml->sml_nvalues = NULL;
ml->sml_numvals = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment