mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
Fix some potential memory leaks in cdr_pgsql.
Issue 10020, patch by my, with credit to prashant_jois for pointing out the problem. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@70612 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -86,6 +86,7 @@ static int pgsql_log(struct ast_cdr *cdr)
|
|||||||
connected = 1;
|
connected = 1;
|
||||||
} else {
|
} else {
|
||||||
pgerror = PQerrorMessage(conn);
|
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: 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);
|
||||||
}
|
}
|
||||||
@@ -145,6 +146,7 @@ static int pgsql_log(struct ast_cdr *cdr)
|
|||||||
connected = 1;
|
connected = 1;
|
||||||
} else {
|
} else {
|
||||||
pgerror = PQerrorMessage(conn);
|
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: Unable to reconnect 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);
|
||||||
connected = 0;
|
connected = 0;
|
||||||
@@ -162,6 +164,7 @@ static int pgsql_log(struct ast_cdr *cdr)
|
|||||||
if (PQstatus(conn) == CONNECTION_OK) {
|
if (PQstatus(conn) == CONNECTION_OK) {
|
||||||
ast_log(LOG_ERROR, "cdr_pgsql: Connection reestablished.\n");
|
ast_log(LOG_ERROR, "cdr_pgsql: Connection reestablished.\n");
|
||||||
connected = 1;
|
connected = 1;
|
||||||
|
PQclear(result);
|
||||||
result = PQexec(conn, sqlcmd);
|
result = PQexec(conn, sqlcmd);
|
||||||
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
|
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
|
||||||
pgerror = PQresultErrorMessage(result);
|
pgerror = PQresultErrorMessage(result);
|
||||||
|
Reference in New Issue
Block a user