Fix crash due to empty strings in keys

This commit is contained in:
Jules Aguillon 2025-02-27 22:00:32 +01:00
parent 44d1343b83
commit ba05b2770e

View File

@ -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();