diff -aur asterisk.ori/apps/app_voicemail.c asterisk/apps/app_voicemail.c --- asterisk.ori/apps/app_voicemail.c 2006-09-07 11:10:53.000000000 -0500 +++ asterisk/apps/app_voicemail.c 2006-09-07 14:57:55.000000000 -0500 @@ -7524,7 +7524,6 @@ context = ast_variable_retrieve(msg_cfg, "message", "context"); if (!strncasecmp("macro",context,5)) /* Macro names in contexts are useless for our needs */ context = ast_variable_retrieve(msg_cfg, "message","macrocontext"); - ast_config_destroy(msg_cfg); #endif switch (option) { case 3: @@ -7548,8 +7547,10 @@ if (num) { /* Dial the CID number */ res = dialout(chan, vmu, num, vmu->callback); - if (res) - return 9; + if (res) { + res = 9; + goto yuck; + } } else { res = '2'; } @@ -7559,14 +7560,16 @@ /* Want to enter a different number, can only do this if there's a dialout context for this user */ if (!ast_strlen_zero(vmu->dialout)) { res = dialout(chan, vmu, NULL, vmu->dialout); - if (res) - return 9; + if (res) { + res = 9; + goto yuck; + } } else { if (option_verbose > 2) ast_verbose( VERBOSE_PREFIX_3 "Caller can not specify callback number - no dialout context available\n"); res = ast_play_and_wait(chan, "vm-sorry"); } - return res; + goto yuck; case '*': res = 't'; break; @@ -7633,7 +7636,7 @@ ast_verbose(VERBOSE_PREFIX_3 "No CID number available, no reply sent\n"); if (!res) res = ast_play_and_wait(chan, "vm-nonumber"); - return res; + goto yuck; } else { if (find_user(NULL, vmu->context, num)) { struct leave_vm_options leave_options; @@ -7649,14 +7652,14 @@ res = leave_voicemail(chan, mailbox, &leave_options); if (!res) res = 't'; - return res; + goto yuck; } else { /* Sender has no mailbox, can't reply */ if (option_verbose > 2) ast_verbose( VERBOSE_PREFIX_3 "No mailbox number '%s' in context '%s', no reply sent\n", num, vmu->context); ast_play_and_wait(chan, "vm-nobox"); res = 't'; - return res; + goto yuck; } } res = 0; @@ -7665,14 +7668,16 @@ } #ifndef IMAP_STORAGE - ast_config_destroy(msg_cfg); - if (!res) { make_file(vms->fn, sizeof(vms->fn), vms->curdir, msg); vms->heard[msg] = 1; res = wait_file(chan, vms, vms->fn); } #endif +yuck: +#ifndef IMAP_STORAGE + ast_config_destroy(msg_cfg); +#endif return res; }