Index: channels/chan_agent.c =================================================================== --- channels/chan_agent.c (revision 143400) +++ channels/chan_agent.c (working copy) @@ -2492,7 +2492,9 @@ /* First, take us out of the channel loop */ ast_channel_unregister(&agent_tech); /* Delete devicestate subscription */ - ast_event_unsubscribe(agent_devicestate_sub); + if (agent_devicestate_sub) { + ast_event_unsubscribe(agent_devicestate_sub); + } /* Unregister dialplan functions */ ast_custom_function_unregister(&agent_function); /* Unregister CLI commands */