From 8e5ffde8163b7eaffac35a9c266ef88a4fbb7acb Mon Sep 17 00:00:00 2001 From: Matthew Jordan Date: Fri, 26 Apr 2013 21:26:39 +0000 Subject: [PATCH] Clean up memory leak in config file on off nominal paths when glob is allowed If a system allows for its usage, Asterisk will use glob to help parse Asterisk .conf files. The config file loading routine was leaking the memory allocated by the glob() routine when the config file was in an unmodified or invalid state. This patch properly calls globfree in those off nominal paths. (closes issue ASTERISK-21412) Reported by: Corey Farrell patches: config_glob_leak.patch uploaded by Corey Farrell (license 5909) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@386672 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/config.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main/config.c b/main/config.c index f90cfc1638..0ff2d841e9 100644 --- a/main/config.c +++ b/main/config.c @@ -1493,6 +1493,9 @@ static struct ast_config *config_text_file_load(const char *database, const char AST_LIST_UNLOCK(&cfmtime_head); ast_free(comment_buffer); ast_free(lline_buffer); +#ifdef AST_INCLUDE_GLOB + globfree(&globbuf); +#endif return CONFIG_STATUS_FILEUNCHANGED; } } @@ -1503,6 +1506,9 @@ static struct ast_config *config_text_file_load(const char *database, const char if (cfg == NULL) { ast_free(comment_buffer); ast_free(lline_buffer); +#ifdef AST_INCLUDE_GLOB + globfree(&globbuf); +#endif return NULL; }