[asterisk-commits] rmudgett: branch 10 r332830 - in /branches/10: ./ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 22 13:32:13 CDT 2011


Author: rmudgett
Date: Mon Aug 22 13:32:09 2011
New Revision: 332830

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=332830
Log:
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.
........

Modified:
    branches/10/   (props changed)
    branches/10/res/res_config_odbc.c
    branches/10/res/res_config_pgsql.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/res/res_config_odbc.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/res/res_config_odbc.c?view=diff&rev=332830&r1=332829&r2=332830
==============================================================================
--- branches/10/res/res_config_odbc.c (original)
+++ branches/10/res/res_config_odbc.c Mon Aug 22 13:32:09 2011
@@ -419,7 +419,7 @@
 			if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
 				ast_log(LOG_WARNING, "SQL Describe Column error!\n[%s]\n\n", sql);
 				ast_category_destroy(cat);
-				continue;
+				goto next_sql_fetch;
 			}
 
 			indicator = 0;
@@ -430,7 +430,7 @@
 			if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
 				ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
 				ast_category_destroy(cat);
-				continue;
+				goto next_sql_fetch;
 			}
 			stringp = rowdata;
 			while (stringp) {
@@ -448,6 +448,7 @@
 			}
 		}
 		ast_category_append(cfg, cat);
+next_sql_fetch:;
 	}
 
 	SQLFreeHandle(SQL_HANDLE_STMT, stmt);

Modified: branches/10/res/res_config_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/res/res_config_pgsql.c?view=diff&rev=332830&r1=332829&r2=332830
==============================================================================
--- branches/10/res/res_config_pgsql.c (original)
+++ branches/10/res/res_config_pgsql.c Mon Aug 22 13:32:09 2011
@@ -566,6 +566,7 @@
 			PQfinish(pgsqlConn);
 			pgsqlConn = NULL;
 		}
+		ast_config_destroy(cfg);
 		return NULL;
 	}
 
@@ -586,6 +587,7 @@
 	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 @@
 		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 @@
 	/* 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 @@
 						PQresultErrorMessage(result), PQresStatus(result_status));
 			PQclear(result);
 			ast_mutex_unlock(&pgsql_lock);
+			ast_config_destroy(cfg);
 			return NULL;
 		}
 	}
@@ -648,6 +653,7 @@
 		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++)




More information about the asterisk-commits mailing list