aboutsummaryrefslogtreecommitdiffstats
path: root/cdr
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-26 18:30:29 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-26 18:30:29 +0000
commit5bdf298fc7e4e1f610ee759f6c769e5ce84c8630 (patch)
tree8006031f26b38f9b41d6cf7f4775bb180e5545fd /cdr
parent8ea8956f9bcb13b75c6f5fe69a2101b76e8b11f1 (diff)
Two consecutive calls to PQfinish could occur, meaning free gets called on the same variable twice.
This patch sets the connection to NULL after calls to PQfinish so that the problem does not occur. Also in this patch, prashant_jois informed me that it is safe to pass a null pointer to PQfinish, so I have removed the check for conn's existence from my_unload_module. (closes issue 10295, reported by junky, patched by me with input from prashant_jois) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@77318 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'cdr')
-rw-r--r--cdr/cdr_pgsql.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index 1521adaf0..7c2bc9355 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -89,6 +89,7 @@ static int pgsql_log(struct ast_cdr *cdr)
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);
+ conn = NULL;
}
}
@@ -149,6 +150,7 @@ static int pgsql_log(struct ast_cdr *cdr)
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);
+ conn = NULL;
connected = 0;
ast_mutex_unlock(&pgsql_lock);
return -1;
@@ -184,8 +186,7 @@ static int pgsql_log(struct ast_cdr *cdr)
static int my_unload_module(void)
{
- if (conn)
- PQfinish(conn);
+ PQfinish(conn);
if (pghostname)
free(pghostname);
if (pgdbname)