From 7df9bcf5e7609f5e278de240573b07f103bcdb67 Mon Sep 17 00:00:00 2001 From: Tilghman Lesher Date: Tue, 20 Jul 2010 22:23:13 +0000 Subject: [PATCH] Delete IMAP messages in reverse order, to ensure reordering after each expunge does not cause deletion of the wrong message. (closes issue #16350) Reported by: noahisaac Patches: 20100623__issue16350.diff.txt uploaded by tilghman (license 14) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@278261 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_voicemail.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 4fd805fc7e..a02ac78bf4 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -5955,12 +5955,15 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu) DELETE(vms->curdir, x, vms->fn, vmu); } ast_unlock_path(vms->curdir); -#else +#else /* defined(IMAP_STORAGE) */ if (vms->deleted) { - for (x=0;x < vmu->maxmsg;x++) { - if (vms->deleted[x]) { - if (option_debug > 2) - ast_log(LOG_DEBUG,"IMAP delete of %d\n",x); + /* Since we now expunge after each delete, deleting in reverse order + * ensures that no reordering occurs between each step. */ + for (x = vmu->maxmsg - 1; x >= 0; x--) { + if (vms->deleted[x]) { + if (option_debug > 2) { + ast_log(LOG_DEBUG, "IMAP delete of %d\n", x); + } DELETE(vms->curdir, x, vms->fn, vmu); } } -- 2.47.2