]> git.sur5r.net Git - openldap/commitdiff
Don't leak logfiles
authorHoward Chu <hyc@openldap.org>
Tue, 16 Oct 2007 00:59:39 +0000 (00:59 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 16 Oct 2007 00:59:39 +0000 (00:59 +0000)
servers/slapd/bconfig.c

index 5aa496f74d1da8b950987fd146bbe4e57bf849d8..451045bf93d69cf2a69991792f021a28d96e1c92 100644 (file)
@@ -77,6 +77,7 @@ typedef struct {
 static CfBackInfo cfBackInfo;
 
 static char    *passwd_salt;
+static FILE *logfile;
 static char    *logfileName;
 #ifdef SLAP_AUTH_REWRITE
 static BerVarray authz_rewrites;
@@ -1124,6 +1125,10 @@ config_generic(ConfigArgs *c) {
                case CFG_LOGFILE:
                        ch_free( logfileName );
                        logfileName = NULL;
+                       if ( logfile ) {
+                               fclose( logfile );
+                               logfile = NULL;
+                       }
                        break;
 
                case CFG_SERVERID: {
@@ -1683,7 +1688,6 @@ sortval_reject:
                        }
                        break;
                case CFG_LOGFILE: {
-                               FILE *logfile;
                                if ( logfileName ) ch_free( logfileName );
                                logfileName = c->value_string;
                                logfile = fopen(logfileName, "w");