summaryrefslogtreecommitdiff
path: root/res/res_config_pgsql.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2011-08-22 18:33:27 +0000
committerRichard Mudgett <rmudgett@digium.com>2011-08-22 18:33:27 +0000
commitbac5a51e2121a63549941f3a9ce7f7a4c50454ca (patch)
tree499643ebf5ae4f5d4425101aef48d272892e1257 /res/res_config_pgsql.c
parentb8748f4c00263d29d9d30e47172171850d651743 (diff)
Merged revisions 332830 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/10 ................ r332830 | rmudgett | 2011-08-22 13:32:09 -0500 (Mon, 22 Aug 2011) | 15 lines Merged revisions 332816 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r332816 | rmudgett | 2011-08-22 13:14:59 -0500 (Mon, 22 Aug 2011) | 8 lines Memory leaks in realtime_multi_xxx() when database access returns error. * Fix realtime_multi_pgsql() configuration memory leak when the database access returns an error. * Fix realtime_multi_odbc() configuration category use after free when the database access returns an error. ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@332831 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_config_pgsql.c')
-rw-r--r--res/res_config_pgsql.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 6ed6bd294..f8de86596 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -566,6 +566,7 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
PQfinish(pgsqlConn);
pgsqlConn = NULL;
}
+ ast_config_destroy(cfg);
return NULL;
}
@@ -586,6 +587,7 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
if (pgresult) {
ast_log(LOG_ERROR, "PostgreSQL RealTime: detected invalid input: '%s'\n", newval);
va_end(ap);
+ ast_config_destroy(cfg);
return NULL;
}
@@ -601,6 +603,7 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
if (pgresult) {
ast_log(LOG_ERROR, "PostgreSQL RealTime: detected invalid input: '%s'\n", newval);
va_end(ap);
+ ast_config_destroy(cfg);
return NULL;
}
@@ -616,8 +619,9 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
/* We now have our complete statement; Lets connect to the server and execute it. */
ast_mutex_lock(&pgsql_lock);
- if (pgsql_exec(database, table, ast_str_buffer(sql), &result) != 0) {
+ if (pgsql_exec(database, table, ast_str_buffer(sql), &result) != 0) {
ast_mutex_unlock(&pgsql_lock);
+ ast_config_destroy(cfg);
return NULL;
} else {
ExecStatusType result_status = PQresultStatus(result);
@@ -631,6 +635,7 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
PQresultErrorMessage(result), PQresStatus(result_status));
PQclear(result);
ast_mutex_unlock(&pgsql_lock);
+ ast_config_destroy(cfg);
return NULL;
}
}
@@ -648,6 +653,7 @@ static struct ast_config *realtime_multi_pgsql(const char *database, const char
if (!(fieldnames = ast_calloc(1, numFields * sizeof(char *)))) {
PQclear(result);
ast_mutex_unlock(&pgsql_lock);
+ ast_config_destroy(cfg);
return NULL;
}
for (i = 0; i < numFields; i++)