From: Anthony Minessale Date: Tue, 2 Mar 2010 21:14:46 +0000 (+0000) Subject: fix seg on bug removal X-Git-Tag: v1.0.6~270 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=686efff6d227dfa58e3c28ca21e70e7bcdf6473a;p=thirdparty%2Ffreeswitch.git fix seg on bug removal git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16870 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- diff --git a/src/switch_core_media_bug.c b/src/switch_core_media_bug.c index b85e4b6aff..c5a39ac6b8 100644 --- a/src/switch_core_media_bug.c +++ b/src/switch_core_media_bug.c @@ -461,16 +461,18 @@ SWITCH_DECLARE(switch_status_t) switch_core_media_bug_remove(switch_core_session } switch_thread_rwlock_unlock(session->bug_rwlock); if (bp) { - switch_event_t *event; + switch_event_t *event = NULL; - 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_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); - switch_event_fire(&event); - } + 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) { + switch_event_fire(&event); + } else { + switch_event_destroy(&event); } } }