We should only unsubscribe to the device state event
authorMark Michelson <mmichelson@digium.com>
Fri, 19 Sep 2008 15:43:28 +0000 (15:43 +0000)
committerMark Michelson <mmichelson@digium.com>
Fri, 19 Sep 2008 15:43:28 +0000 (15:43 +0000)
subscription if we have previously subscribed. Otherwise
a segfault will occur.

(closes issue #13476)
Reported by: jonnt
Patches:
      13476.patch uploaded by putnopvut (license 60)
Tested by: jonnt

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@143609 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_agent.c

index 83dbd38..f84c0f0 100644 (file)
@@ -2535,7 +2535,9 @@ static int unload_module(void)
        /* First, take us out of the channel loop */
        ast_channel_unregister(&agent_tech);
        /* Delete devicestate subscription */
-       agent_devicestate_sub = ast_event_unsubscribe(agent_devicestate_sub);
+       if (agent_devicestate_sub) {
+               agent_devicestate_sub = ast_event_unsubscribe(agent_devicestate_sub);
+       }
        /* Unregister dialplan functions */
        ast_custom_function_unregister(&agent_function);        
        /* Unregister CLI commands */