[svn-commits] tilghman: branch 1.6.1 r139709 - in /branches/1.6.1: ./ cdr/cdr_pgsql.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Aug 24 11:36:10 CDT 2008


Author: tilghman
Date: Sun Aug 24 11:36:09 2008
New Revision: 139709

URL: http://svn.digium.com/view/asterisk?view=rev&rev=139709
Log:
Merged revisions 139707 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
r139707 | tilghman | 2008-08-24 11:26:48 -0500 (Sun, 24 Aug 2008) | 2 lines

Memory leak

........

Modified:
    branches/1.6.1/   (props changed)
    branches/1.6.1/cdr/cdr_pgsql.c

Propchange: branches/1.6.1/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.1/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.1/cdr/cdr_pgsql.c?view=diff&rev=139709&r1=139708&r2=139709
==============================================================================
--- branches/1.6.1/cdr/cdr_pgsql.c (original)
+++ branches/1.6.1/cdr/cdr_pgsql.c Sun Aug 24 11:36:09 2008
@@ -132,7 +132,17 @@
 		int lensql, lensql2, sizesql = maxsize, sizesql2 = maxsize2, newsize;
 		char *sql = ast_calloc(sizeof(char), sizesql), *sql2 = ast_calloc(sizeof(char), sizesql2), *tmp, *value;
 		char buf[257], escapebuf[513];
-  
+ 
+		if (!sql || !sql2) {
+			if (sql) {
+				ast_free(sql);
+			}
+			if (sql2) {
+				ast_free(sql2);
+			}
+			return -1;
+		}
+ 
 		lensql = snprintf(sql, sizesql, "INSERT INTO %s (", table);
 		lensql2 = snprintf(sql2, sizesql2, " VALUES (");
   
@@ -288,6 +298,8 @@
 				conn = NULL;
 				connected = 0;
 				ast_mutex_unlock(&pgsql_lock);
+				ast_free(sql);
+				ast_free(sql2);
 				return -1;
 			}
 		}
@@ -311,9 +323,13 @@
 			}
 			ast_mutex_unlock(&pgsql_lock);
 			PQclear(result);
+			ast_free(sql);
+			ast_free(sql2);
 			return -1;
 		}
 		PQclear(result);
+		ast_free(sql);
+		ast_free(sql2);
 	}
 	ast_mutex_unlock(&pgsql_lock);
 	return 0;




More information about the svn-commits mailing list