From 46e9cbb0ba9e15ffde7ab5b887b83fd2ac28deca Mon Sep 17 00:00:00 2001 From: lsnow Date: Sat, 18 Oct 2025 22:04:29 +0800 Subject: [PATCH] NotificationManager: check for null before adding an action button --- src/api-impl-jni/app/android_app_NotificationManager.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/api-impl-jni/app/android_app_NotificationManager.c b/src/api-impl-jni/app/android_app_NotificationManager.c index bafcdd9e..055e2b99 100644 --- a/src/api-impl-jni/app/android_app_NotificationManager.c +++ b/src/api-impl-jni/app/android_app_NotificationManager.c @@ -96,7 +96,9 @@ JNIEXPORT void JNICALL Java_android_app_NotificationManager_nativeAddAction(JNIE const char *name = ""; if (name_jstr) name = (*env)->GetStringUTFChars(env, name_jstr, NULL); - g_notification_add_button_with_target_value(notification, name, intent_actionname_from_type(type), intent_serialize(env, intent)); + const char *action = intent_actionname_from_type(type); + if (action) + g_notification_add_button_with_target_value(notification, name, action, intent_serialize(env, intent)); if (name_jstr) (*env)->ReleaseStringUTFChars(env, name_jstr, name); } @@ -129,7 +131,9 @@ JNIEXPORT void JNICALL Java_android_app_NotificationManager_nativeShowNotificati g_free(icon_path_full); (*env)->ReleaseStringUTFChars(env, icon_jstr, icon_path); } - g_notification_set_default_action_and_target_value(notification, intent_actionname_from_type(type), intent_serialize(env, intent)); + const char *action = intent_actionname_from_type(type); + if (action) + g_notification_set_default_action_and_target_value(notification, action, intent_serialize(env, intent)); queue_notification(id, notification); if (ongoing) g_hash_table_add(ongoing_notifications, GINT_TO_POINTER(id));