fix free()ing of config items
- we need to free the config after it has been succesfully loaded, not unconditionally before reloading. - we also need to free them before exiting from the main program to have clean valgrind output.
This commit is contained in:
		
							parent
							
								
									372d7ff824
								
							
						
					
					
						commit
						9d5ee85c3e
					
				@ -286,7 +286,7 @@ free_added_headers (vector_t add_headers)
 | 
				
			|||||||
        vector_delete (add_headers);
 | 
					        vector_delete (add_headers);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void free_config (struct config_s *conf)
 | 
					void free_config (struct config_s *conf)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
        safefree (conf->logf_name);
 | 
					        safefree (conf->logf_name);
 | 
				
			||||||
        safefree (conf->stathost);
 | 
					        safefree (conf->stathost);
 | 
				
			||||||
@ -467,8 +467,6 @@ int reload_config_file (const char *config_fname, struct config_s *conf)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        log_message (LOG_NOTICE, "Reloading config file");
 | 
					        log_message (LOG_NOTICE, "Reloading config file");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        free_config (conf);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        initialize_config_defaults (conf);
 | 
					        initialize_config_defaults (conf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ret = load_config_file (config_fname, conf);
 | 
					        ret = load_config_file (config_fname, conf);
 | 
				
			||||||
 | 
				
			|||||||
@ -116,5 +116,6 @@ struct config_s {
 | 
				
			|||||||
extern int reload_config_file (const char *config_fname, struct config_s *conf);
 | 
					extern int reload_config_file (const char *config_fname, struct config_s *conf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int config_compile_regex (void);
 | 
					int config_compile_regex (void);
 | 
				
			||||||
 | 
					void free_config (struct config_s *conf);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
				
			|||||||
@ -264,6 +264,7 @@ int reload_config (int reload_logging)
 | 
				
			|||||||
                goto done;
 | 
					                goto done;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if(config) free_config (config);
 | 
				
			||||||
        config = c_next;
 | 
					        config = c_next;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (reload_logging) ret = setup_logging ();
 | 
					        if (reload_logging) ret = setup_logging ();
 | 
				
			||||||
@ -415,6 +416,8 @@ main (int argc, char **argv)
 | 
				
			|||||||
                filter_destroy ();
 | 
					                filter_destroy ();
 | 
				
			||||||
#endif /* FILTER_ENABLE */
 | 
					#endif /* FILTER_ENABLE */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        free_config (config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        shutdown_logging ();
 | 
					        shutdown_logging ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return EXIT_SUCCESS;
 | 
					        return EXIT_SUCCESS;
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user