diff -ruN res/res_stasis_snoop.c res/res_stasis_snoop.c --- res/res_stasis_snoop.c +++ res/res_stasis_snoop.c @@ -345,6 +345,9 @@ struct ast_channel *stasis_app_control_snoop(struct ast_channel *chan, return NULL; } + /* Keep a reference to the channel we are spying on */ + snoop->spyee_chan = ast_channel_ref(chan); + /* To keep the channel valid on the Snoop structure until it is destroyed we bump the ref up here */ ast_channel_ref(snoop->chan); @@ -414,9 +417,6 @@ struct ast_channel *stasis_app_control_snoop(struct ast_channel *chan, return NULL; } - /* Keep a reference to the channel we are spying on */ - snoop->spyee_chan = ast_channel_ref(chan); - publish_chanspy_message(snoop, 1); /* The caller of this has a reference as well */