From ba05b2770e6a9aa79b9b44ad4a3d0fab8f199bd3 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Thu, 27 Feb 2025 22:00:32 +0100 Subject: [PATCH] Fix crash due to empty strings in keys --- srcs/juloo.keyboard2/ComposeKey.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/srcs/juloo.keyboard2/ComposeKey.java b/srcs/juloo.keyboard2/ComposeKey.java index 57b2a4e..9571c03 100644 --- a/srcs/juloo.keyboard2/ComposeKey.java +++ b/srcs/juloo.keyboard2/ComposeKey.java @@ -46,13 +46,15 @@ public final class ComposeKey matched. */ public static KeyValue apply(int prev, String s) { + final int len = s.length(); int i = 0; + if (len == 0) return null; while (true) { KeyValue k = apply(prev, s.charAt(i)); i++; if (k == null) return null; - if (i >= s.length()) return k; + if (i >= len) return k; if (k.getKind() != KeyValue.Kind.Compose_pending) return null; // Found a final state before the end of [s]. prev = k.getPendingCompose();