]> git.sur5r.net Git - openldap/commitdiff
ITS#7750 fix olcDbConfig modification
authorHoward Chu <hyc@openldap.org>
Tue, 19 Nov 2013 04:39:35 +0000 (20:39 -0800)
committerHoward Chu <hyc@openldap.org>
Tue, 19 Nov 2013 04:39:35 +0000 (20:39 -0800)
servers/slapd/back-bdb/config.c

index 7a7d72bfa72355a83ce8d91a2d0d59f41dc61843..85b1842dce64f559e366306d6790c0654c7f7c21 100644 (file)
@@ -324,6 +324,7 @@ bdb_cf_cleanup( ConfigArgs *c )
 {
        struct bdb_info *bdb = c->be->be_private;
        int rc = 0;
+       BerVarray bva;
 
        if ( bdb->bi_flags & BDB_DEL_INDEX ) {
                bdb_attr_flush( bdb );
@@ -332,16 +333,22 @@ bdb_cf_cleanup( ConfigArgs *c )
 
        if ( bdb->bi_flags & BDB_RE_OPEN ) {
                bdb->bi_flags ^= BDB_RE_OPEN;
+               bva = bdb->bi_db_config;
+               bdb->bi_db_config = NULL;
                rc = c->be->bd_info->bi_db_close( c->be, &c->reply );
                if ( rc == 0 ) {
                        if ( bdb->bi_flags & BDB_UPD_CONFIG ) {
-                               if ( bdb->bi_db_config ) {
+                               if ( bva ) {
                                        int i;
                                        FILE *f = fopen( bdb->bi_db_config_path, "w" );
                                        if ( f ) {
+                                               bdb->bi_db_config = bva;
+                                               bva = NULL;
                                                for (i=0; bdb->bi_db_config[i].bv_val; i++)
                                                        fprintf( f, "%s\n", bdb->bi_db_config[i].bv_val );
                                                fclose( f );
+                                       } else {
+                                               ber_bvarray_free( bva );
                                        }
                                } else {
                                        unlink( bdb->bi_db_config_path );