From e1fea9f05d15770814525c8ec9a63b171ca89c0f Mon Sep 17 00:00:00 2001 From: AI-DEV-BOT Date: Fri, 29 May 2026 23:29:08 +0900 Subject: [PATCH] Harden active notification button indexing --- .../NotificationActiveStyle.cs | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationActiveStyle.cs b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationActiveStyle.cs index 8261dbfd9ce..6e2b6218aeb 100755 --- a/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationActiveStyle.cs +++ b/src/Tizen.Applications.Notification/Tizen.Applications.Notifications/NotificationActiveStyle.cs @@ -241,10 +241,20 @@ public void AddButtonAction(ButtonAction button) if (button.Index == ButtonIndex.None) { - button.Index = (ButtonIndex)buttonDictionary.Count; - buttonDictionary.Add(button.Index, button); + for (int i = (int)ButtonIndex.First; i <= (int)ButtonIndex.Third; i++) + { + ButtonIndex index = (ButtonIndex)i; + if (buttonDictionary.ContainsKey(index) == false) + { + button.Index = index; + buttonDictionary.Add(index, button); + return; + } + } + + throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "too many ButtonAction objects"); } - else if (button.Index >= ButtonIndex.First) + else if (button.Index >= ButtonIndex.First && button.Index <= ButtonIndex.Third) { if (buttonDictionary.ContainsKey(button.Index)) { @@ -253,6 +263,10 @@ public void AddButtonAction(ButtonAction button) buttonDictionary.Add(button.Index, button); } + else + { + throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid ButtonAction index"); + } } ///