]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix seg on bug removal
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 2 Mar 2010 21:14:46 +0000 (21:14 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 2 Mar 2010 21:14:46 +0000 (21:14 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16870 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_core_media_bug.c

index b85e4b6affc271c89dd790a1cc2e7c0eb3e39470..c5a39ac6b84113d9030bc15974c2207a8d2fe4e4 100644 (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);
                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);
                        }
                }
        }