From bf7f1ec0f85159e702c483a7d9c578d773240ce1 Mon Sep 17 00:00:00 2001
From: Joshua Colp <jcolp@digium.com>
Date: Thu, 30 Mar 2006 17:58:16 +0000
Subject: [PATCH] Merged revisions 16534 via svnmerge from
 https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r16534 | file | 2006-03-30 13:55:28 -0400 (Thu, 30 Mar 2006) | 2 lines

Do not exceed the array size for maximum allowed moh files. (issue #6842)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@16535 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 res/res_musiconhold.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 289d139d07..4c0f932135 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -776,6 +776,11 @@ static int moh_scan_files(struct mohclass *class) {
 
 		if (i == class->total_files)
 			strcpy(class->filearray[class->total_files++], filepath);
+
+		/* If the new total files is equal to the maximum allowed, stop adding new ones */
+		if (class->total_files == MAX_MOHFILES)
+			break;
+
 	}
 
 	closedir(files_DIR);
-- 
GitLab