mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-01 14:15:49 +08:00
consistently use SLAP_* malloc macros; alloc sizeof(Syntax *) instead of sizeof(Syntax) for areray of superiors; free resources also in case of failure of syn_insert()
This commit is contained in:
parent
3771d2ed49
commit
51152d83a3
@ -196,14 +196,19 @@ syn_add(
|
||||
for ( cnt = 0; def->sd_sups[cnt] != NULL; cnt++ )
|
||||
;
|
||||
|
||||
ssyn->ssyn_sups = (Syntax **)ch_calloc( cnt + 1,
|
||||
sizeof(Syntax) );
|
||||
ssyn->ssyn_sups = (Syntax **)SLAP_CALLOC( cnt + 1,
|
||||
sizeof( Syntax * ) );
|
||||
if ( ssyn->ssyn_sups == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "SLAP_CALLOC Error\n", 0, 0, 0 );
|
||||
code = SLAP_SCHERR_OUTOFMEM;
|
||||
|
||||
for ( cnt = 0; def->sd_sups[cnt] != NULL; cnt++ ) {
|
||||
ssyn->ssyn_sups[cnt] = syn_find( def->sd_sups[cnt] );
|
||||
if ( ssyn->ssyn_sups[cnt] == NULL ) {
|
||||
*err = def->sd_sups[cnt];
|
||||
code = SLAP_SCHERR_SYN_SUP_NOT_FOUND;
|
||||
} else {
|
||||
for ( cnt = 0; def->sd_sups[cnt] != NULL; cnt++ ) {
|
||||
ssyn->ssyn_sups[cnt] = syn_find( def->sd_sups[cnt] );
|
||||
if ( ssyn->ssyn_sups[cnt] == NULL ) {
|
||||
*err = def->sd_sups[cnt];
|
||||
code = SLAP_SCHERR_SYN_SUP_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -211,9 +216,11 @@ syn_add(
|
||||
if ( code == 0 ) {
|
||||
code = syn_insert( ssyn, err );
|
||||
|
||||
} else if ( ssyn != NULL ) {
|
||||
}
|
||||
|
||||
if ( code != 0 && ssyn != NULL ) {
|
||||
if ( ssyn->ssyn_sups != NULL ) {
|
||||
ch_free( ssyn->ssyn_sups );
|
||||
SLAP_FREE( ssyn->ssyn_sups );
|
||||
}
|
||||
SLAP_FREE( ssyn );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user