[asterisk-commits] tilghman: branch 1.2 r63359 - /branches/1.2/apps/app_voicemail.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon May 7 23:20:17 MST 2007


Author: tilghman
Date: Tue May  8 01:20:16 2007
New Revision: 63359

URL: http://svn.digium.com/view/asterisk?view=rev&rev=63359
Log:
Issue 9527 - upon entering a folder, no message is selected (curmsg == -1), so deleting causes memory corruption (beyond bounds)

Modified:
    branches/1.2/apps/app_voicemail.c

Modified: branches/1.2/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/apps/app_voicemail.c?view=diff&rev=63359&r1=63358&r2=63359
==============================================================================
--- branches/1.2/apps/app_voicemail.c (original)
+++ branches/1.2/apps/app_voicemail.c Tue May  8 01:20:16 2007
@@ -5443,21 +5443,24 @@
 			}
 			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':



More information about the asterisk-commits mailing list