[Freeswitch-svn] [commit] r12251 - in freeswitch/trunk/src/mod: applications/mod_easyroute applications/mod_enum dialplans/mod_dialplan_directory endpoints/mod_alsa endpoints/mod_dingaling endpoints/mod_iax endpoints/mod_reference endpoints/mod_skypiax event_handlers/mod_erlang_event event_handlers/mod_event_multicast event_handlers/mod_event_socket loggers/mod_syslog xml_int/mod_xml_rpc

FreeSWITCH SVN mrene at freeswitch.org
Mon Feb 23 11:17:24 PST 2009


Author: mrene
Date: Mon Feb 23 13:17:24 2009
New Revision: 12251

Log:
Leaking on unload is strictly forbidden

Modified:
   freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c
   freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c
   freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
   freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c
   freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
   freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
   freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c
   freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c
   freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
   freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
   freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
   freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c
   freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c

Modified: freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c	Mon Feb 23 13:17:24 2009
@@ -426,6 +426,14 @@
 #ifdef SWITCH_HAVE_ODBC
 	switch_odbc_handle_disconnect(globals.master_odbc);
 #endif
+	
+	switch_safe_free(globals.db_username);
+	switch_safe_free(globals.db_password);
+	switch_safe_free(globals.db_dsn);
+	switch_safe_free(globals.default_techprofile);
+	switch_safe_free(globals.default_gateway);
+	switch_safe_free(globals.custom_query);
+
 	return SWITCH_STATUS_UNLOAD;
 }
 

Modified: freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c	(original)
+++ freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c	Mon Feb 23 13:17:24 2009
@@ -850,6 +850,9 @@
 	if (globals.pool) {
 		switch_core_destroy_memory_pool(&globals.pool);
 	}
+	
+	switch_safe_free(globals.root);
+	switch_safe_free(globals.isn_root);
 
 	return SWITCH_STATUS_UNLOAD;
 }

Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c
==============================================================================
--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c	(original)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c	Mon Feb 23 13:17:24 2009
@@ -35,7 +35,7 @@
 #include <fcntl.h>
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_dialplan_directory_load);
-SWITCH_MODULE_DEFINITION(mod_dialplan_directory, mod_dialplan_directory_load, NULL, NULL);
+SWITCH_MODULE_DEFINITION(mod_dialplan_directory, mod_dialplan_directory_load, mod_dialplan_directory_shutdown, NULL);
 
 static struct {
 	char *directory_name;
@@ -142,11 +142,23 @@
 }
 
 
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_enum_shutdown)
+{
+	switch_safe_free(globals.directory_name);
+	switch_safe_free(globals.host);
+	switch_safe_free(globals.dn);
+	switch_safe_free(globals.pass);
+	switch_safe_free(globals.base);
+}
+
+
 SWITCH_MODULE_LOAD_FUNCTION(mod_dialplan_directory_load)
 {
 	switch_dialplan_interface_t *dp_interface;
 
+	memset(&globals, 0, sizeof(globals));
 	load_config();
+	
 	/* connect my internal structure to the blank pointer passed to me */
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
 	SWITCH_ADD_DIALPLAN(dp_interface, "directory", directory_dialplan_hunt);

Modified: freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c	Mon Feb 23 13:17:24 2009
@@ -813,7 +813,7 @@
 		return SWITCH_STATUS_TERM;
 	}
 
-
+	memset(&globals, 0, sizeof(globals));
 
 	if ((status = load_config()) != SWITCH_STATUS_SUCCESS) {
 		return status;
@@ -939,6 +939,14 @@
 		switch_core_codec_destroy(&globals.write_codec);
 	}
 	switch_core_hash_destroy(&globals.call_hash);
+	
+	switch_safe_free(globals.dialplan);
+	switch_safe_free(globals.cid_name);
+	switch_safe_free(globals.cid_num);
+	switch_safe_free(globals.ring_file);
+	switch_safe_free(globals.hold_file);
+	switch_safe_free(globals.timer_name);
+	switch_safe_free(globals.device_name);
 
 	return SWITCH_STATUS_SUCCESS;
 }

Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c	Mon Feb 23 13:17:24 2009
@@ -1748,6 +1748,8 @@
 	switch_api_interface_t *api_interface;
 
 	module_pool = pool;
+	
+	memset(&globals, 0, sizeof(globals));
 
 	load_config();
 
@@ -1889,6 +1891,11 @@
 
 
 	switch_core_hash_destroy(&globals.profile_hash);
+
+	switch_safe_free(globals.dialplan);
+	switch_safe_free(globals.codec_string);
+	switch_safe_free(globals.codec_rates_string);	
+	
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c	Mon Feb 23 13:17:24 2009
@@ -802,6 +802,8 @@
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_iax_load)
 {
+	memset(&globals, 0, sizeof(globals));
+		
 	module_pool = pool;
 
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
@@ -1148,6 +1150,12 @@
 		}
 		switch_yield(20000);
 	}
+	
+	switch_safe_free(globals.dialplan);
+	switch_safe_free(globals.codec_string);
+	switch_safe_free(globals.codec_rates_string);
+	switch_safe_free(globals.ip);
+	
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c	Mon Feb 23 13:17:24 2009
@@ -532,6 +532,8 @@
 
 	module_pool = pool;
 
+	memset(&globals, 0, sizeof(globals));
+
 	load_config();
 
 	*module_interface = switch_loadable_module_create_module_interface(pool, modname);
@@ -565,6 +567,13 @@
 		}
 		switch_yield(20000);
 	}
+	
+	/* Free dynamically allocated strings */
+	switch_safe_free(globals.dialplan);
+	switch_safe_free(globals.codec_string);
+	switch_safe_free(globals.codec_rates_string);
+	switch_safe_free(globals.ip);
+	
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	Mon Feb 23 13:17:24 2009
@@ -1071,6 +1071,13 @@
                          globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread);
     }
   }
+
+  switch_safe_free(globals.dialplan);
+  switch_safe_free(globals.context);
+  switch_safe_free(globals.destination);
+  switch_safe_free(globals.codec_string);
+  switch_safe_free(globals.codec_rates_string);
+
   return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c	(original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c	Mon Feb 23 13:17:24 2009
@@ -1296,7 +1296,9 @@
 {
 	switch_application_interface_t *app_interface;
 	switch_api_interface_t *api_interface;
-
+	
+	memset(&prefs, 0, sizeof(prefs));
+	
 	switch_mutex_init(&globals.listener_mutex, SWITCH_MUTEX_NESTED, pool);
 	
 	/* intialize the unique reference stuff */
@@ -1517,6 +1519,10 @@
 
 	switch_sleep(1500000); /* sleep for 1.5 seconds */
 
+	switch_safe_free(prefs.ip);
+	switch_safe_free(prefs.cookie);
+	switch_safe_free(prefs.nodename);
+
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c	(original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c	Mon Feb 23 13:17:24 2009
@@ -267,6 +267,9 @@
 
 	switch_core_hash_destroy(&globals.event_hash);
 
+	switch_safe_free(globals.address);
+	switch_safe_free(globals.bindings);
+
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	(original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c	Mon Feb 23 13:17:24 2009
@@ -471,6 +471,9 @@
 
 	switch_event_unbind(&globals.node);
 
+	switch_safe_free(prefs.ip);
+	switch_safe_free(prefs.password);	
+
 	return SWITCH_STATUS_SUCCESS;
 }
 
@@ -933,6 +936,8 @@
 	switch_application_interface_t *app_interface;
 	switch_api_interface_t *api_interface;
 
+	memset(&globals, 0, sizeof(globals));
+
 	switch_mutex_init(&globals.listener_mutex, SWITCH_MUTEX_NESTED, pool);
 
 	memset(&listen_list, 0, sizeof(listen_list));

Modified: freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c
==============================================================================
--- freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c	(original)
+++ freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c	Mon Feb 23 13:17:24 2009
@@ -152,6 +152,8 @@
 {
 	switch_status_t status;
 	*module_interface = &console_module_interface;
+	
+	memset(&globals, 0, sizeof(globals));
 
 	if ((status = load_config()) != SWITCH_STATUS_SUCCESS) {
 		return status;
@@ -162,6 +164,9 @@
 	setlogmask(LOG_UPTO(LOG_DEBUG));
 	switch_log_bind_logger(mod_syslog_logger, log_level, SWITCH_FALSE);
 
+	switch_safe_free(globals.ident);
+	switch_safe_free(globals.format);
+
 	return SWITCH_STATUS_SUCCESS;
 }
 

Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c	(original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c	Mon Feb 23 13:17:24 2009
@@ -851,6 +851,10 @@
 		switch_yield(100000);
 	} while (globals.running);
 
+	switch_safe_free(globals.realm);
+	switch_safe_free(globals.user);
+	switch_safe_free(globals.pass);
+
 	return SWITCH_STATUS_SUCCESS;
 }
 



More information about the Freeswitch-svn mailing list