The patch seems to fix the problem. Thanks.

On Wed, Sep 3, 2025 at 4:39 AM Po Lu <luangruo@yahoo.com> wrote:
Fake Baka <spoof1024@gmail.com> writes:

> (gdb) frame 10
> #10 0x0000555555705a0d in xi_disable_devices (dpyinfo=0x55555649d8d0, to_disable=0x7fffffffbbc0, n_disabled=4) at xterm.c:13966
> 13966     xfree (dpyinfo->devices);
> (gdb) list
> 13961             continue;
> 13962           }
> 13963       }
> 13964
> 13965     /* Free the old devices array and replace it with ndevices.  */
> 13966     xfree (dpyinfo->devices);
> 13967
> 13968     dpyinfo->devices = devices;
> 13969     dpyinfo->num_devices = ndevices;
> 13970   }

Please test this patch and ack:

diff --git a/src/xterm.c b/src/xterm.c
index 02151fd2ced..e56d1d5f11d 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -13945,12 +13945,11 @@ xi_disable_devices (struct x_display_info *dpyinfo,

              goto out;
            }
-
-         devices[ndevices++] = dpyinfo->devices[i];
-
-       out:
-         continue;
        }
+
+      devices[ndevices++] = dpyinfo->devices[i];
+    out:
+      continue;
     }

   /* Free the old devices array and replace it with ndevices.  */