Merged revisions 63360 via svnmerge from
authorTilghman Lesher <tilghman@meg.abyt.es>
Tue, 8 May 2007 06:26:02 +0000 (06:26 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Tue, 8 May 2007 06:26:02 +0000 (06:26 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

................
r63360 | tilghman | 2007-05-08 01:22:37 -0500 (Tue, 08 May 2007) | 10 lines

Merged revisions 63359 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r63359 | tilghman | 2007-05-08 01:20:16 -0500 (Tue, 08 May 2007) | 2 lines

Issue 9527 - upon entering a folder, no message is selected (curmsg == -1), so deleting causes memory corruption (beyond bounds)

........

................

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

apps/app_voicemail.c

index 521fdc7..e31f743 100644 (file)
@@ -6783,21 +6783,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;
 #ifdef IMAP_STORAGE
                        deleted = 1;
 #endif