[Freeswitch-svn] [commit] r11932 - freeswitch/trunk/src/mod/applications/mod_limit

FreeSWITCH SVN mrene at freeswitch.org
Thu Feb 12 12:31:29 PST 2009


Author: mrene
Date: Thu Feb 12 14:31:29 2009
New Revision: 11932

Log:
fix leak

Modified:
   freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c

Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c	Thu Feb 12 14:31:29 2009
@@ -422,6 +422,7 @@
 		cbt.len = sizeof(buf);
 		sql = switch_mprintf("select data from db_data where realm='%q' and data_key='%q'", argv[1], argv[2]);
 		limit_execute_sql_callback(NULL, sql, sql2str_callback, &cbt);
+		switch_safe_free(sql);
 		stream->write_function(stream, "%s", buf);
 		goto done;
 	}
@@ -476,9 +477,10 @@
 		return;
 	}
 
-	switch_assert(sql);
-	limit_execute_sql(sql, globals.mutex);
-	switch_safe_free(sql);
+	if (sql) {
+		limit_execute_sql(sql, globals.mutex);
+		switch_safe_free(sql);
+	}
 }
 
 #define HASH_USAGE "[insert|delete]/<realm>/<key>/<val>"
@@ -648,8 +650,11 @@
 		assert(sql);
 
 		limit_execute_sql_callback(NULL, sql, group_callback, &cbt);
+		switch_safe_free(sql);
+		
 		*(buf + (strlen(buf) - 1)) = '\0';
 		stream->write_function(stream, "%s", buf);
+
 		goto done;
 	}
 
@@ -750,6 +755,7 @@
 	cbt.len = sizeof(buf);
 	sql = switch_mprintf("select count(hostname) from limit_data where realm='%q' and id like '%q'", realm, id);
 	limit_execute_sql_callback(NULL, sql, sql2str_callback, &cbt);
+	switch_safe_free(sql);
 	got = atoi(buf);
 
 	if (got + 1 > max) {



More information about the Freeswitch-svn mailing list