[asterisk-commits] tilghman: branch 1.6.0 r139708 - in /branches/1.6.0: ./ cdr/cdr_pgsql.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Aug 24 11:30:54 CDT 2008


Author: tilghman
Date: Sun Aug 24 11:30:54 2008
New Revision: 139708

URL: http://svn.digium.com/view/asterisk?view=rev&rev=139708
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.0/   (props changed)
    branches/1.6.0/cdr/cdr_pgsql.c

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

Modified: branches/1.6.0/cdr/cdr_pgsql.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/cdr/cdr_pgsql.c?view=diff&rev=139708&r1=139707&r2=139708
==============================================================================
--- branches/1.6.0/cdr/cdr_pgsql.c (original)
+++ branches/1.6.0/cdr/cdr_pgsql.c Sun Aug 24 11:30:54 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 asterisk-commits mailing list