From 0f0cc43e1bb86a133b99599db1b7d01fdf34fe00 Mon Sep 17 00:00:00 2001
From: Naveen Albert <asterisk@phreaknet.org>
Date: Sun, 22 May 2022 01:40:16 +0000
Subject: [PATCH] say: Abort play loop if caller hangs up.

If the caller has hung up, break out of the play loop so we don't try
to play remaining files and fail to do so.

ASTERISK-30075 #close

Change-Id: I55e85be28ee90b48c0fe4ce20ac136a7dbb49f14
---
 main/say.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/main/say.c b/main/say.c
index 8fb5e97607..b60d4bff3c 100644
--- a/main/say.c
+++ b/main/say.c
@@ -189,19 +189,13 @@ static int say_filenames(struct ast_channel *chan, const char *ints, const char
 
 	files = ast_str_buffer(filenames);
 
-	while ((fn = strsep(&files, "&"))) {
+	while (!res && (fn = strsep(&files, "&"))) {
 		res = ast_streamfile(chan, fn, lang);
 		if (!res) {
-			if ((audiofd  > -1) && (ctrlfd > -1))
+			if ((audiofd  > -1) && (ctrlfd > -1)) {
 				res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
-			else
+			} else {
 				res = ast_waitstream(chan, ints);
-
-			if (res > 0) {
-				/* We were interrupted by a digit */
-				ast_stopstream(chan);
-				ast_free(filenames);
-				return res;
 			}
 		}
 		ast_stopstream(chan);
-- 
GitLab