diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-09-20 16:10:57 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-09-20 16:10:57 +0000 |
commit | 43a4eed03510937efa2a5c023459af42358e1786 (patch) | |
tree | ed98e7ee5cd2a8248c3d68224d04f1d998d2481b /cdr | |
parent | a35dd640cdbbe41347f01d70d63065349d0d7f77 (diff) |
Fix memory leaks in pbx_dundi, cdr_pgsql, and the configuration file parser.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@83229 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cdr')
-rw-r--r-- | cdr/cdr_pgsql.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c index d3813c65a..ac43e96f8 100644 --- a/cdr/cdr_pgsql.c +++ b/cdr/cdr_pgsql.c @@ -216,8 +216,10 @@ static int config_module(int reload) } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) return 0; - if (!(var = ast_variable_browse(cfg, "global"))) + if (!(var = ast_variable_browse(cfg, "global"))) { + ast_config_destroy(cfg); return 0; + } if (!(tmp = ast_variable_retrieve(cfg, "global", "hostname"))) { ast_log(LOG_WARNING, "PostgreSQL server hostname not specified. Assuming unix socket connection\n"); @@ -226,8 +228,10 @@ static int config_module(int reload) if (pghostname) ast_free(pghostname); - if (!(pghostname = ast_strdup(tmp))) + if (!(pghostname = ast_strdup(tmp))) { + ast_config_destroy(cfg); return -1; + } if (!(tmp = ast_variable_retrieve(cfg, "global", "dbname"))) { ast_log(LOG_WARNING,"PostgreSQL database not specified. Assuming asterisk\n"); @@ -236,8 +240,10 @@ static int config_module(int reload) if (pgdbname) ast_free(pgdbname); - if (!(pgdbname = ast_strdup(tmp))) + if (!(pgdbname = ast_strdup(tmp))) { + ast_config_destroy(cfg); return -1; + } if (!(tmp = ast_variable_retrieve(cfg, "global", "user"))) { ast_log(LOG_WARNING,"PostgreSQL database user not specified. Assuming asterisk\n"); @@ -246,8 +252,10 @@ static int config_module(int reload) if (pgdbuser) ast_free(pgdbuser); - if (!(pgdbuser = ast_strdup(tmp))) + if (!(pgdbuser = ast_strdup(tmp))) { + ast_config_destroy(cfg); return -1; + } if (!(tmp = ast_variable_retrieve(cfg, "global", "password"))) { ast_log(LOG_WARNING,"PostgreSQL database password not specified. Assuming blank\n"); @@ -256,8 +264,10 @@ static int config_module(int reload) if (pgpassword) ast_free(pgpassword); - if (!(pgpassword = ast_strdup(tmp))) + if (!(pgpassword = ast_strdup(tmp))) { + ast_config_destroy(cfg); return -1; + } if (!(tmp = ast_variable_retrieve(cfg,"global","port"))) { ast_log(LOG_WARNING,"PostgreSQL database port not specified. Using default 5432.\n"); @@ -266,8 +276,10 @@ static int config_module(int reload) if (pgdbport) ast_free(pgdbport); - if (!(pgdbport = ast_strdup(tmp))) + if (!(pgdbport = ast_strdup(tmp))) { + ast_config_destroy(cfg); return -1; + } if (!(tmp = ast_variable_retrieve(cfg, "global", "table"))) { ast_log(LOG_WARNING,"CDR table not specified. Assuming cdr\n"); @@ -276,8 +288,10 @@ static int config_module(int reload) if (table) ast_free(table); - if (!(table = ast_strdup(tmp))) + if (!(table = ast_strdup(tmp))) { + ast_config_destroy(cfg); return -1; + } if (option_debug) { if (ast_strlen_zero(pghostname)) @@ -302,6 +316,8 @@ static int config_module(int reload) connected = 0; } + ast_config_destroy(cfg); + return ast_cdr_register(name, ast_module_info->description, pgsql_log); } |