From 8c4582e29fd098df5c06e7db7147a103d6d73d85 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Thu, 21 Jun 2007 00:10:02 +0000 Subject: [PATCH] fix potential leak (detected by Coverity) --- servers/slapd/syntax.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/servers/slapd/syntax.c b/servers/slapd/syntax.c index b9fb273fe2..8faffad041 100644 --- a/servers/slapd/syntax.c +++ b/servers/slapd/syntax.c @@ -164,9 +164,9 @@ syn_add( int code = 0; ssyn = (Syntax *) SLAP_CALLOC( 1, sizeof(Syntax) ); - if( ssyn == NULL ) { + if ( ssyn == NULL ) { Debug( LDAP_DEBUG_ANY, "SLAP_CALLOC Error\n", 0, 0, 0 ); - return LDAP_OTHER; + return SLAP_SCHERR_OUTOFMEM; } AC_MEMCPY( &ssyn->ssyn_syn, syn, sizeof(LDAPSyntax) ); @@ -183,6 +183,8 @@ syn_add( ssyn->ssyn_validate = def->sd_validate; ssyn->ssyn_pretty = def->sd_pretty; + ssyn->ssyn_sups = NULL; + #ifdef SLAPD_BINARY_CONVERSION ssyn->ssyn_ber2str = def->sd_ber2str; ssyn->ssyn_str2ber = def->sd_str2ber; @@ -208,6 +210,12 @@ syn_add( if ( code == 0 ) { code = syn_insert( ssyn, err ); + + } else if ( ssyn != NULL ) { + if ( ssyn->ssyn_sups != NULL ) { + ch_free( ssyn->ssyn_sups ); + } + SLAP_FREE( ssyn ); } return code; -- 2.39.5