diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 6f6a932863..dca093d43d 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -1744,6 +1744,7 @@ static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu, int box) ast_log(LOG_WARNING, "The code expects the old messages to be checked first, fix the code.\n"); } if (vm_allocate_dh(vms, vmu, box == 0 ? vms->vmArrayIndex + vms->oldmessages : vms->lastmsg)) { + ast_mutex_unlock(&vms->lock); return -1; } @@ -5969,7 +5970,7 @@ static int open_mailbox(struct vm_state *vms, struct ast_vm_user *vmu,int box) /* for local storage, checks directory for messages up to maxmsg limit */ last_msg = last_message_index(vmu, vms->curdir); - if (last_msg < 0) + if (last_msg < -1) return last_msg; else if (vms->lastmsg != last_msg) {