aboutsummaryrefslogtreecommitdiffstats
path: root/cdr
diff options
context:
space:
mode:
authorqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-20 23:33:49 +0000
committerqwell <qwell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-20 23:33:49 +0000
commitb46a50d87a963a3f0ea78c7b3ddbd04ca57764a0 (patch)
treeb28cedec95974b42dae9accd0035a7bc382ebb6e /cdr
parent2c3c35ec2b1777fca8ae13777c396cfd30f83dce (diff)
Merged revisions 70612 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r70612 | qwell | 2007-06-20 18:32:39 -0500 (Wed, 20 Jun 2007) | 4 lines Fix some potential memory leaks in cdr_pgsql. Issue 10020, patch by me, with credit to prashant_jois for pointing out the problem. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@70613 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cdr')
-rw-r--r--cdr/cdr_pgsql.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index 4f3901c98..2379d7728 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -87,8 +87,9 @@ static int pgsql_log(struct ast_cdr *cdr)
connected = 1;
} else {
pgerror = PQerrorMessage(conn);
+ PQfinish(conn);
ast_log(LOG_ERROR, "cdr_pgsql: Unable to connect to database server %s. Calls will not be logged!\n", pghostname);
- ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
+ ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
}
}
@@ -144,6 +145,7 @@ static int pgsql_log(struct ast_cdr *cdr)
connected = 1;
} else {
pgerror = PQerrorMessage(conn);
+ PQfinish(conn);
ast_log(LOG_ERROR, "cdr_pgsql: Unable to reconnect to database server %s. Calls will not be logged!\n", pghostname);
ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
connected = 0;
@@ -161,6 +163,7 @@ static int pgsql_log(struct ast_cdr *cdr)
if (PQstatus(conn) == CONNECTION_OK) {
ast_log(LOG_ERROR, "cdr_pgsql: Connection reestablished.\n");
connected = 1;
+ PQclear(result);
result = PQexec(conn, sqlcmd);
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
pgerror = PQresultErrorMessage(result);