From d1030c67182d3096d1e292ce13a72b24d3d19f3e Mon Sep 17 00:00:00 2001 From: Pewnack <[email protected]> Date: Sun, 22 Mar 2026 14:03:59 +0100 Subject: [PATCH] Data returned from XLib/XGetEventData is not guaranteed to be aligned. --- src/native/linux_x11/xi_input.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/native/linux_x11/xi_input.rs b/src/native/linux_x11/xi_input.rs index a5e62056..ffb6f987 100644 --- a/src/native/linux_x11/xi_input.rs +++ b/src/native/linux_x11/xi_input.rs @@ -123,8 +123,10 @@ impl LibXi { let raw_event = xcookie.data as *mut xi_input::XIRawEvent; - let dx = *(*raw_event).raw_values; - let dy = *(*raw_event).raw_values.offset(1); + // Data returned from Xlib is not guaranteed to be aligned + let ptr = (*raw_event).raw_values as *const u8; + let dx = std::ptr::read_unaligned(ptr as *const f64); + let dy = std::ptr::read_unaligned(ptr.add(1) as *const f64); (self.XFreeEventData)(display, &mut (*xcookie) as *mut _);