From: Naveen Albert Date: Sun, 24 Oct 2021 12:31:37 +0000 (+0000) Subject: app_voicemail: Fix phantom voicemail bug on rerecord X-Git-Tag: 16.23.0-rc1~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54b41fcfd200c4d84d2b7264e553c2883e2ec105;p=thirdparty%2Fasterisk.git app_voicemail: Fix phantom voicemail bug on rerecord If users are able to press # for options while leaving a message and then press 3 to rerecord the message, if the caller hangs up during the rerecord prompt but before Asterisk starts recording a message, then an "empty" voicemail gets processed whereby an email gets sent out notifying the user of a 0:00 duration message. The file doesn't actually exist, so playback will fail since there was no message to begin with. This adds a check after the streaming of the rerecord announcement to see if the caller has hung up. If so, we bail out early so that we can clean up properly. ASTERISK-29391 #close Change-Id: Id965d72759a2fd3b39afb76fec08aaebebe75c31 --- diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 43aa5dd433..cb70f9e062 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -15862,6 +15862,12 @@ static int play_record_review(struct ast_channel *chan, char *playfile, char *re } cmd = ast_play_and_wait(chan, "beep"); } + if (cmd == -1) { + /* User has hung up, no options to give */ + ast_debug(1, "User hung up before message could be rerecorded\n"); + ast_filedelete(tempfile, NULL); + return cmd; + } recorded = 1; /* After an attempt has been made to record message, we have to take care of INTRO and beep for incoming messages, but not for greetings */ if (record_gain)