]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Issue 9527 - upon entering a folder, no message is selected (curmsg == -1), so deleti...
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 8 May 2007 06:20:16 +0000 (06:20 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 8 May 2007 06:20:16 +0000 (06:20 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@63359 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c

index ce6b545fd73be81f0da6c362cdb6304e97996493..caa81a3fd7ee10b2b9684bb7550221bc94e20467 100644 (file)
@@ -5443,21 +5443,24 @@ static int vm_execmain(struct ast_channel *chan, void *data)
                        }
                        break;
                case '7':
-                       vms.deleted[vms.curmsg] = !vms.deleted[vms.curmsg];
-                       if (useadsi)
-                               adsi_delete(chan, &vms);
-                       if (vms.deleted[vms.curmsg]) 
-                               cmd = ast_play_and_wait(chan, "vm-deleted");
-                       else
-                               cmd = ast_play_and_wait(chan, "vm-undeleted");
-                       if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) {
-                               if (vms.curmsg < vms.lastmsg) {
-                                       vms.curmsg++;
-                                       cmd = play_message(chan, vmu, &vms);
-                               } else {
-                                       cmd = ast_play_and_wait(chan, "vm-nomore");
+                       if (vms.curmsg >= 0 && vms.curmsg <= vms.lastmsg) {
+                               vms.deleted[vms.curmsg] = !vms.deleted[vms.curmsg];
+                               if (useadsi)
+                                       adsi_delete(chan, &vms);
+                               if (vms.deleted[vms.curmsg]) 
+                                       cmd = ast_play_and_wait(chan, "vm-deleted");
+                               else
+                                       cmd = ast_play_and_wait(chan, "vm-undeleted");
+                               if (ast_test_flag((&globalflags), VM_SKIPAFTERCMD)) {
+                                       if (vms.curmsg < vms.lastmsg) {
+                                               vms.curmsg++;
+                                               cmd = play_message(chan, vmu, &vms);
+                                       } else {
+                                               cmd = ast_play_and_wait(chan, "vm-nomore");
+                                       }
                                }
-                       }
+                       } else /* Delete not valid if we haven't selected a message */
+                               cmd = 0;
                        break;
        
                case '8':