diff options
author | Mark Michelson <mmichelson@digium.com> | 2007-07-06 16:39:11 +0000 |
---|---|---|
committer | Mark Michelson <mmichelson@digium.com> | 2007-07-06 16:39:11 +0000 |
commit | 80f8dd3f812acb9c8a9bde16297411dcc6675fed (patch) | |
tree | ef1abcefedcc4db9a10bdb1afcda7f7992525afd | |
parent | d544d6377ec011cf6aef7e8dc13ef07b56d18ba4 (diff) |
Merged revisions 73727 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r73727 | mmichelson | 2007-07-06 11:36:17 -0500 (Fri, 06 Jul 2007) | 8 lines
Fixing a rare case which causes voicemail to crash when compiled with IMAP storage.
inboxcount has the possibility of finding an "interactive" vm_state when no persistent "non-interactive"
vm_state exists for that mailbox. If this should happen when someone attempts to leave a message, it results in
a crash. This patch, along with my commit in revision 72670 fix issue 10053, reported by jaroth.
closes issue #10053
........
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@73728 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | apps/app_voicemail.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 130695b57..ab9e7906c 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -3183,8 +3183,24 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_ ast_log(LOG_NOTICE,"Can not leave voicemail, unable to count messages\n"); return -1; } - if((vms = get_vm_state_by_mailbox(ext,0))) - vms->newmessages++; /*still need to increment new message count*/ + if(!(vms = get_vm_state_by_mailbox(ext,0))) { + /*It is possible under certain circumstances that inboxcount did not create a vm_state when it was needed. This is a catchall which will + * rarely be used*/ + if (!(vms = ast_calloc(1, sizeof(*vms)))) { + ast_log(LOG_ERROR, "Couldn't allocate necessary space\n"); + return -1; + } + ast_copy_string(vms->imapuser, vmu->imapuser, sizeof(vms->imapuser)); + ast_copy_string(vms->username, ext, sizeof(vms->username)); + vms->mailstream = NIL; + ast_debug(3, "Copied %s to %s\n", vmu->imapuser, vms->imapuser); + vms->updated=1; + ast_copy_string(vms->curbox, mbox(0), sizeof(vms->curbox)); + init_vm_state(vms); + vmstate_insert(vms); + vms = get_vm_state_by_mailbox(ext,0); + } + vms->newmessages++; /* here is a big difference! We add one to it later */ msgnum = newmsgs + oldmsgs; |