]> git.sur5r.net Git - openldap/commitdiff
Fix config mem leak
authorKurt Zeilenga <kurt@openldap.org>
Sat, 10 Aug 2002 00:12:58 +0000 (00:12 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sat, 10 Aug 2002 00:12:58 +0000 (00:12 +0000)
servers/slapd/config.c
servers/slapd/tools/slapcommon.c

index 5362cbdb9efd245576f6511f89b5c45be9ee054b..0046551709c614c046b8e1d63b292dd47bc37855 100644 (file)
@@ -75,7 +75,7 @@ static char   *strtok_quote(char *line, char *sep);
 static int      load_ucdata(char *path);
 
 int
-read_config( const char *fname )
+read_config( const char *fname, int depth )
 {
        FILE    *fp;
        char    *line, *savefname, *saveline;
@@ -90,8 +90,10 @@ read_config( const char *fname )
 
        vals[1].bv_val = NULL;
 
-       cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
-       cargv_size = ARGS_STEP + 1;
+       if ( depth == 0 ) {
+               cargv = ch_calloc( ARGS_STEP + 1, sizeof(*cargv) );
+               cargv_size = ARGS_STEP + 1;
+       }
 
        if ( (fp = fopen( fname, "r" )) == NULL ) {
                ldap_syslog = 1;
@@ -2012,7 +2014,7 @@ read_config( const char *fname )
                        savefname = ch_strdup( cargv[1] );
                        savelineno = lineno;
 
-                       if ( read_config( savefname ) != 0 ) {
+                       if ( read_config( savefname, depth+1 ) != 0 ) {
                                return( 1 );
                        }
 
@@ -2257,6 +2259,8 @@ read_config( const char *fname )
        }
        fclose( fp );
 
+       if ( depth == 0 ) ch_free( cargv );
+
        if ( load_ucdata( NULL ) < 0 ) return 1;
        return( 0 );
 }
index abe5b7abeb754ee50f234627758e243640aa7887..27c6712724d3f3ec3bdeea300d39c063f7d8109b 100644 (file)
@@ -195,7 +195,7 @@ slap_tool_init(
                exit( EXIT_FAILURE );
        }
 
-       rc = read_config( conffile );
+       rc = read_config( conffile, 0 );
 
        if ( rc != 0 ) {
                fprintf( stderr, "%s: bad configuration file!\n", progname );