]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
don't deref NULL. Found by Klockwork (www.klocwork.com)
authorMichael Jerris <mike@jerris.com>
Tue, 27 May 2008 20:04:04 +0000 (20:04 +0000)
committerMichael Jerris <mike@jerris.com>
Tue, 27 May 2008 20:04:04 +0000 (20:04 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8700 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/event_handlers/mod_event_socket/mod_event_socket.c

index 0f48e689f6dfbb7c1c01ffcf11b5f77e0692a7f2..852a6a7cbfacacb1724e15b376cdf777a3e80a9d 100644 (file)
@@ -532,6 +532,11 @@ static switch_status_t read_packet(listener_t *listener, switch_event_t **event,
                                                }
                                        }
 
+                                       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 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
        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 @@ static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
        }
 
   done:
-       if (acs && acs->bg) {
+       if (acs->bg) {
                switch_memory_pool_t *pool = acs->pool;
                acs = NULL;
                switch_core_destroy_memory_pool(&pool);