[asterisk-commits] qwell: branch 1.4 r70612 - /branches/1.4/cdr/cdr_pgsql.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 20 18:32:39 CDT 2007


Author: qwell
Date: Wed Jun 20 18:32:39 2007
New Revision: 70612

URL: http://svn.digium.com/view/asterisk?view=rev&rev=70612
Log:
Fix some potential memory leaks in cdr_pgsql.

Issue 10020, patch by my, with credit to prashant_jois for pointing out the problem.

Modified:
    branches/1.4/cdr/cdr_pgsql.c

Modified: branches/1.4/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/cdr/cdr_pgsql.c?view=diff&rev=70612&r1=70611&r2=70612
==============================================================================
--- branches/1.4/cdr/cdr_pgsql.c (original)
+++ branches/1.4/cdr/cdr_pgsql.c Wed Jun 20 18:32:39 2007
@@ -86,8 +86,9 @@
 			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);
 		}
 	}
 
@@ -145,6 +146,7 @@
 				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;
@@ -162,6 +164,7 @@
 			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);




More information about the asterisk-commits mailing list