[Freeswitch-svn] [commit] r8700 - freeswitch/trunk/src/mod/event_handlers/mod_event_socket

Freeswitch SVN mikej at freeswitch.org
Tue May 27 16:04:04 EDT 2008


Author: mikej
Date: Tue May 27 16:04:04 2008
New Revision: 8700

Modified:
   freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c

Log:
don't deref NULL. Found by Klockwork (www.klocwork.com)

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	Tue May 27 16:04:04 2008
@@ -532,6 +532,11 @@
 						}
 					}
 
+					if (!listener->ebuf) {
+						switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No event data (allocation error?)\n");
+						goto endloop;
+					}
+
 					len = strlen(listener->ebuf);
 
 					switch_snprintf(hbuf, sizeof(hbuf), "Content-Length: %" SWITCH_SSIZE_T_FMT "\n" "Content-Type: text/event-%s\n" "\n", len, etype);
@@ -577,6 +582,11 @@
 	char *reply, *freply = NULL;
 	switch_status_t status;
 
+	if (!acs) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Internal error.\n");
+		return NULL;
+	}
+
 	if (!acs->listener || !acs->listener->rwlock || switch_thread_rwlock_tryrdlock(acs->listener->rwlock) != SWITCH_STATUS_SUCCESS) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error! cannot get read lock.\n");
 		goto done;
@@ -631,7 +641,7 @@
 	}
 
   done:
-	if (acs && acs->bg) {
+	if (acs->bg) {
 		switch_memory_pool_t *pool = acs->pool;
 		acs = NULL;
 		switch_core_destroy_memory_pool(&pool);



More information about the Freeswitch-svn mailing list