[Freeswitch-svn] [commit] r2479 - in freeswitch/trunk/src: . mod/applications/mod_commands
Freeswitch SVN
mikej at freeswitch.org
Sat Sep 2 03:31:19 EDT 2006
Author: mikej
Date: Sat Sep 2 03:31:18 2006
New Revision: 2479
Modified:
freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
freeswitch/trunk/src/switch_core.c
Log:
fix crash when passing null string to switch_core_session_locate (via killchan with no param)
Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c Sat Sep 2 03:31:18 2006
@@ -117,7 +117,7 @@
return SWITCH_STATUS_FALSE;
}
- if ((session = switch_core_session_locate(dest))) {
+ if (dest && (session = switch_core_session_locate(dest))) {
switch_channel_t *channel = switch_core_session_get_channel(session);
switch_core_session_kill_channel(session, SWITCH_SIG_KILL);
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c (original)
+++ freeswitch/trunk/src/switch_core.c Sat Sep 2 03:31:18 2006
@@ -269,18 +269,22 @@
{
switch_core_session_t *session;
- switch_mutex_lock(runtime.session_table_mutex);
- if ((session = switch_core_hash_find(runtime.session_table, uuid_str))) {
- /* Acquire a read lock on the session */
- if (switch_thread_rwlock_tryrdlock(session->rwlock) != SWITCH_STATUS_SUCCESS) {
- /* not available, forget it */
- session = NULL;
+ if (uuid_str) {
+ switch_mutex_lock(runtime.session_table_mutex);
+ if ((session = switch_core_hash_find(runtime.session_table, uuid_str))) {
+ /* Acquire a read lock on the session */
+ if (switch_thread_rwlock_tryrdlock(session->rwlock) != SWITCH_STATUS_SUCCESS) {
+ /* not available, forget it */
+ session = NULL;
+ }
}
- }
- switch_mutex_unlock(runtime.session_table_mutex);
+ switch_mutex_unlock(runtime.session_table_mutex);
- /* if its not NULL, now it's up to you to rwunlock this */
- return session;
+ /* if its not NULL, now it's up to you to rwunlock this */
+ return session;
+ } else {
+ return NULL;
+ }
}
SWITCH_DECLARE(void) switch_core_session_hupall(void)
More information about the Freeswitch-svn
mailing list