Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 188149) +++ apps/app_voicemail.c (working copy) @@ -5025,7 +5025,7 @@ char fmt[80]; char *context; char ecodes[17] = "#"; - char tmp[1024] = ""; + struct ast_str *tmp = ast_str_create(16); char *tmpptr; struct ast_vm_user *vmu; struct ast_vm_user svm; @@ -5034,9 +5034,12 @@ const char *alldtmf = "0123456789ABCD*#"; char flag[80]; - ast_copy_string(tmp, ext, sizeof(tmp)); - ext = tmp; - if ((context = strchr(tmp, '@'))) { + if (!tmp) { + return -1; + } + ast_str_set(&tmp, 0, "%s", ext); + ext = ast_str_buffer(tmp); + if ((context = strchr(ext, '@'))) { *context++ = '\0'; tmpptr = strchr(context, '&'); } else { @@ -5064,6 +5067,7 @@ if (!(vmu = find_user(&svm, context, ext))) { ast_log(AST_LOG_WARNING, "No entry in voicemail config file for '%s'\n", ext); pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); + ast_free(tmp); return res; } /* Setup pre-file if appropriate */ @@ -5089,6 +5093,7 @@ snprintf(tempfile, sizeof(tempfile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, ext); if ((res = create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, ext, "tmp"))) { ast_log(AST_LOG_WARNING, "Failed to make directory (%s)\n", tempfile); + ast_free(tmp); return -1; } RETRIEVE(tempfile, -1, vmu->mailbox, vmu->context); @@ -5159,6 +5164,7 @@ ast_debug(1, "Hang up during prefile playback\n"); free_user(vmu); pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); + ast_free(tmp); return -1; } } @@ -5189,6 +5195,7 @@ chan->priority = 0; free_user(vmu); pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT"); + ast_free(tmp); return 0; } @@ -5208,6 +5215,7 @@ free_user(vmu); pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT"); } + ast_free(tmp); return 0; } @@ -5217,12 +5225,14 @@ ast_copy_string(chan->context, options->exitcontext, sizeof(chan->context)); free_user(vmu); pbx_builtin_setvar_helper(chan, "VMSTATUS", "USEREXIT"); + ast_free(tmp); return res; } if (res < 0) { free_user(vmu); pbx_builtin_setvar_helper(chan, "VMSTATUS", "FAILED"); + ast_free(tmp); return -1; } /* The meat of recording the message... All the announcements and beeps have been played*/ @@ -5236,6 +5246,7 @@ res = inboxcount(ext_context, &newmsgs, &oldmsgs); if (res < 0) { ast_log(AST_LOG_NOTICE, "Can not leave voicemail, unable to count messages\n"); + ast_free(tmp); return -1; } if (!(vms = get_vm_state_by_mailbox(ext, context, 0))) { @@ -5245,6 +5256,7 @@ */ if (!(vms = create_vm_state_from_user(vmu))) { ast_log(AST_LOG_ERROR, "Couldn't allocate necessary space\n"); + ast_free(tmp); return -1; } } @@ -5262,6 +5274,7 @@ if (vms->quota_limit && vms->quota_usage >= vms->quota_limit) { ast_debug(1, "*** QUOTA EXCEEDED!! %u >= %u\n", vms->quota_usage, vms->quota_limit); ast_play_and_wait(chan, "vm-mailboxfull"); + ast_free(tmp); return -1; } @@ -5269,6 +5282,7 @@ if (msgnum >= vmu->maxmsg) { ast_log(AST_LOG_WARNING, "Unable to leave message since we will exceed the maximum number of messages allowed (%u > %u)\n", msgnum, vmu->maxmsg); ast_play_and_wait(chan, "vm-mailboxfull"); + ast_free(tmp); return -1; } #else @@ -5476,7 +5490,8 @@ ast_mutex_unlock(&vms->lock); } #endif - + + ast_free(tmp); return res; }