]> git.sur5r.net Git - openldap/commitdiff
consistently use SLAP_* malloc macros; alloc sizeof(Syntax *) instead of sizeof(Synta...
authorPierangelo Masarati <ando@openldap.org>
Thu, 16 Aug 2007 12:08:47 +0000 (12:08 +0000)
committerPierangelo Masarati <ando@openldap.org>
Thu, 16 Aug 2007 12:08:47 +0000 (12:08 +0000)
servers/slapd/syntax.c

index 8faffad0413ed7c96b2ff0db2c9563b6d6b0b1de..249f3681d9449df45f56784e9dbbdd15e8c1e52e 100644 (file)
@@ -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) );
-
-               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;
+               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;
+
+               } 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 );
        }