[asterisk-commits] file: trunk r83229 - in /trunk: cdr/cdr_pgsql.c main/config.c pbx/pbx_dundi.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Sep 20 11:10:57 CDT 2007
Author: file
Date: Thu Sep 20 11:10:57 2007
New Revision: 83229
URL: http://svn.digium.com/view/asterisk?view=rev&rev=83229
Log:
Fix memory leaks in pbx_dundi, cdr_pgsql, and the configuration file parser.
Modified:
trunk/cdr/cdr_pgsql.c
trunk/main/config.c
trunk/pbx/pbx_dundi.c
Modified: trunk/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/trunk/cdr/cdr_pgsql.c?view=diff&rev=83229&r1=83228&r2=83229
==============================================================================
--- trunk/cdr/cdr_pgsql.c (original)
+++ trunk/cdr/cdr_pgsql.c Thu Sep 20 11:10:57 2007
@@ -216,8 +216,10 @@
} 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 @@
if (pghostname)
ast_free(pghostname);
- if (!(pghostname = ast_strdup(tmp)))
- return -1;
+ 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 @@
if (pgdbname)
ast_free(pgdbname);
- if (!(pgdbname = ast_strdup(tmp)))
- return -1;
+ 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 @@
if (pgdbuser)
ast_free(pgdbuser);
- if (!(pgdbuser = ast_strdup(tmp)))
- return -1;
+ 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 @@
if (pgpassword)
ast_free(pgpassword);
- if (!(pgpassword = ast_strdup(tmp)))
- return -1;
+ 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 @@
if (pgdbport)
ast_free(pgdbport);
- if (!(pgdbport = ast_strdup(tmp)))
- return -1;
+ 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 @@
if (table)
ast_free(table);
- if (!(table = ast_strdup(tmp)))
- return -1;
+ if (!(table = ast_strdup(tmp))) {
+ ast_config_destroy(cfg);
+ return -1;
+ }
if (option_debug) {
if (ast_strlen_zero(pghostname))
@@ -302,6 +316,8 @@
connected = 0;
}
+ ast_config_destroy(cfg);
+
return ast_cdr_register(name, ast_module_info->description, pgsql_log);
}
Modified: trunk/main/config.c
URL: http://svn.digium.com/view/asterisk/trunk/main/config.c?view=diff&rev=83229&r1=83228&r2=83229
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Thu Sep 20 11:10:57 2007
@@ -765,6 +765,7 @@
ast_variables_destroy(cat->root);
catn = cat;
cat = cat->next;
+ ast_free(catn->file);
ast_free(catn);
}
ast_free(cfg);
Modified: trunk/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_dundi.c?view=diff&rev=83229&r1=83228&r2=83229
==============================================================================
--- trunk/pbx/pbx_dundi.c (original)
+++ trunk/pbx/pbx_dundi.c Thu Sep 20 11:10:57 2007
@@ -4635,19 +4635,16 @@
int globalpcmodel = 0;
dundi_eid testeid;
- if ((cfg = ast_config_load(config_file, config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ if (!(cfg = ast_config_load(config_file, config_flags))) {
+ ast_log(LOG_ERROR, "Unable to load config %s\n", config_file);
+ return -1;
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
return 0;
dundi_ttl = DUNDI_DEFAULT_TTL;
dundi_cache_time = DUNDI_DEFAULT_CACHE_TIME;
any_peer = NULL;
-
- cfg = ast_config_load(config_file, config_flags);
-
- if (!cfg) {
- ast_log(LOG_ERROR, "Unable to load config %s\n", config_file);
- return -1;
- }
+
ipaddr[0] = '\0';
if (!gethostname(hn, sizeof(hn)-1)) {
hp = ast_gethostbyname(hn, &he);
More information about the asterisk-commits
mailing list