fix seg on bug removal

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16870 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2010-03-02 21:14:46 +00:00
parent 26eb2ea8f1
commit 686efff6d2
1 changed files with 10 additions and 8 deletions

View File

@ -461,16 +461,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session
} }
switch_thread_rwlock_unlock(session->bug_rwlock); switch_thread_rwlock_unlock(session->bug_rwlock);
if (bp) { if (bp) {
switch_event_t *event; switch_event_t *event = NULL;
if (switch_event_create(&event, SWITCH_EVENT_MEDIA_BUG_STOP) == SWITCH_STATUS_SUCCESS) {
switch_channel_event_set_data(session->channel, event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Function", "%s", bp->function);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Target", "%s", bp->target);
}
if ((status = switch_core_media_bug_close(&bp)) == SWITCH_STATUS_SUCCESS) { if ((status = switch_core_media_bug_close(&bp)) == SWITCH_STATUS_SUCCESS) {
if (switch_event_create(&event, SWITCH_EVENT_MEDIA_BUG_STOP) == SWITCH_STATUS_SUCCESS) { switch_event_fire(&event);
switch_channel_event_set_data(session->channel, event); } else {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Function", "%s", bp->function); switch_event_destroy(&event);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Media-Bug-Target", "%s", bp->target);
switch_event_fire(&event);
}
} }
} }
} }