]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
dont segfault when a MWI event occurs on a line without a registered device
authorMichiel van Baak <michiel@vanbaak.info>
Sun, 25 Jan 2009 16:50:53 +0000 (16:50 +0000)
committerMichiel van Baak <michiel@vanbaak.info>
Sun, 25 Jan 2009 16:50:53 +0000 (16:50 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@171081 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_skinny.c

index cacc776b0bd892ab54252fede5a88ea63abb344a..654077e8a060f67a5926c40d0668bea10413a443 100644 (file)
@@ -2513,35 +2513,37 @@ static void mwi_event_cb(const struct ast_event *event, void *userdata)
 {
        struct skinny_line *l = userdata;
        struct skinny_device *d = l->device;
-       struct skinnysession *s = d->session;
-       struct skinny_line *l2;
-       int new_msgs = 0;
-       int dev_msgs = 0;
-
-       if (s) {
-               if (event) {
-                       l->newmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
-               }
+       if (d) {
+               struct skinnysession *s = d->session;
+               struct skinny_line *l2;
+               int new_msgs = 0;
+               int dev_msgs = 0;
+
+               if (s) {
+                       if (event) {
+                               l->newmsgs = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
+                       }
 
-               if (l->newmsgs) {
-                       transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, l->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON);
-               } else {
-                       transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, SKINNY_LAMP_OFF);
-               }
+                       if (l->newmsgs) {
+                               transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, l->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON);
+                       } else {
+                               transmit_lamp_indication(d, STIMULUS_VOICEMAIL, l->instance, SKINNY_LAMP_OFF);
+                       }
 
-               /* find out wether the device lamp should be on or off */
-               AST_LIST_TRAVERSE(&d->lines, l2, list) {
-                       if (l2->newmsgs) {
-                               dev_msgs++;
+                       /* find out wether the device lamp should be on or off */
+                       AST_LIST_TRAVERSE(&d->lines, l2, list) {
+                               if (l2->newmsgs) {
+                                       dev_msgs++;
+                               }
                        }
-               }
 
-               if (dev_msgs) {
-                       transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, d->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON);
-               } else {
-                       transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, SKINNY_LAMP_OFF);
+                       if (dev_msgs) {
+                               transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, d->mwiblink?SKINNY_LAMP_BLINK:SKINNY_LAMP_ON);
+                       } else {
+                               transmit_lamp_indication(d, STIMULUS_VOICEMAIL, 0, SKINNY_LAMP_OFF);
+                       }
+                       ast_verb(3, "Skinny mwi_event_cb found %d new messages\n", new_msgs);
                }
-               ast_verb(3, "Skinny mwi_event_cb found %d new messages\n", new_msgs);
        }
 }