From 75ad52ceced13755ebf3b2f3d2a0d44ccda135a3 Mon Sep 17 00:00:00 2001 From: Shai Almog <67850168+shai-almog@users.noreply.github.com> Date: Thu, 21 May 2026 20:13:20 +0300 Subject: [PATCH] Fix #4997: guard pointerDragged against empty pointer arrays The Android port has been observed to dispatch zero-length pointer arrays into Display.pointerDragged. The previous code routed any length != 1 to the multi-pointer queue, after which Form.pointerDragged unconditionally dereferenced x[0]/y[0] and crashed with ArrayIndexOutOfBoundsException: length=0; index=0. Drop the event at the boundary so a malformed input from a native port can't bring down the EDT. Co-Authored-By: Claude Opus 4.7 (1M context) --- CodenameOne/src/com/codename1/ui/Display.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CodenameOne/src/com/codename1/ui/Display.java b/CodenameOne/src/com/codename1/ui/Display.java index 381aefb11b..630039d20c 100644 --- a/CodenameOne/src/com/codename1/ui/Display.java +++ b/CodenameOne/src/com/codename1/ui/Display.java @@ -2066,6 +2066,10 @@ public void pointerDragged(final int[] x, final int[] y) { if (impl.getCurrentForm() == null) { return; } + if (x.length == 0) { + // Native ports have been observed to deliver zero-length pointer arrays + return; + } longPointerCharged = false; if (x.length == 1) { addPointerDragEventWithTimestamp(x[0], y[0]);