Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 238229) +++ apps/app_voicemail.c (working copy) @@ -174,7 +174,8 @@ #define INTRO "vm-intro" -#define MAXMSG 100 +#define MAXMSG 100 /* Maximum number of messages, soft-limit */ +#define MAXMSG_FUDGE 10 /* The hard limit is this above maxmsg */ #ifndef IMAP_STORAGE #define MAXMSGLIMIT 9999 #else @@ -2782,7 +2783,7 @@ if (vm_lock_path(dir)) return ERROR_LOCK_PATH; - for (x = 0; x < vmu->maxmsg; x++) { + for (x = 0; x < vmu->maxmsg + MAXMSG_FUDGE; x++) { make_file(fn, sizeof(fn), dir, x); if (ast_fileexists(fn, NULL, NULL) < 1) break; @@ -3810,7 +3811,7 @@ if (!EXISTS(todir, recipmsgnum, topath, chan->language)) break; recipmsgnum++; - } while (recipmsgnum < recip->maxmsg); + } while (recipmsgnum < recip->maxmsg + MAXMSG_FUDGE); if (recipmsgnum < recip->maxmsg) { if (EXISTS(fromdir, msgnum, frompath, chan->language)) { COPY(fromdir, msgnum, todir, recipmsgnum, recip->mailbox, recip->context, frompath, topath); @@ -4379,7 +4380,7 @@ if (vm_lock_path(dir)) return ERROR_LOCK_PATH; - for (x = 0, dest = 0; x < vmu->maxmsg; x++) { + for (x = 0, dest = 0; x < vmu->maxmsg + MAXMSG_FUDGE; x++) { make_file(sfn, sizeof(sfn), dir, x); if (EXISTS(dir, x, sfn, NULL)) { @@ -4443,7 +4444,7 @@ if (vm_lock_path(ddir)) return ERROR_LOCK_PATH; - for (x = 0; x < vmu->maxmsg; x++) { + for (x = 0; x < vmu->maxmsg + MAXMSG_FUDGE; x++) { make_file(dfn, sizeof(dfn), ddir, x); if (!EXISTS(ddir, x, dfn, NULL)) break; @@ -5793,7 +5794,7 @@ if (vm_lock_path(vms->curdir)) return ERROR_LOCK_PATH; - for (x = 0; x < vmu->maxmsg; x++) { + for (x = 0; x < vmu->maxmsg + MAXMSG_FUDGE; x++) { if (!vms->deleted[x] && (strcasecmp(vms->curbox, "INBOX") || !vms->heard[x])) { /* Save this message. It's not in INBOX or hasn't been heard */ make_file(vms->fn, sizeof(vms->fn), vms->curdir, x); @@ -5827,7 +5828,7 @@ ast_unlock_path(vms->curdir); #else if (vms->deleted) { - for (x=0;x < vmu->maxmsg;x++) { + for (x = 0; x < vmu->maxmsg + MAXMSG_FUDGE; x++) { if (vms->deleted[x]) { if (option_debug > 2) ast_log(LOG_DEBUG,"IMAP delete of %d\n",x); @@ -5839,9 +5840,9 @@ done: if (vms->deleted) - memset(vms->deleted, 0, vmu->maxmsg * sizeof(int)); + memset(vms->deleted, 0, (vmu->maxmsg + MAXMSG_FUDGE) * sizeof(int)); if (vms->heard) - memset(vms->heard, 0, vmu->maxmsg * sizeof(int)); + memset(vms->heard, 0, (vmu->maxmsg + MAXMSG_FUDGE) * sizeof(int)); return 0; } @@ -7499,10 +7500,10 @@ vmstate_insert(&vms); init_vm_state(&vms); #endif - if (!(vms.deleted = ast_calloc(vmu->maxmsg, sizeof(int)))) { + if (!(vms.deleted = ast_calloc(vmu->maxmsg + MAXMSG_FUDGE, sizeof(int)))) { /* TODO: Handle memory allocation failure */ } - if (!(vms.heard = ast_calloc(vmu->maxmsg, sizeof(int)))) { + if (!(vms.heard = ast_calloc(vmu->maxmsg + MAXMSG_FUDGE, sizeof(int)))) { /* TODO: Handle memory allocation failure */ }