From d287e741b139f93d8cd9b6054095aba8f8ae4941 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 22 Sep 2023 09:18:52 -0700 Subject: [PATCH] apprt/embedded: initialize unmodified keystate prior to use Fixes #521 We were not initializing the dead key state. The dead key state is read on all translation calls so it must be initialized to 0. This was working before because coincidentally whatever the memory was always worked (it probably didn't, but it never didn't work for someone to notice). In debug modes, Zig sets uninitialized memory to 0xAAAAAAAA. Amusingly, this is a valid dead key state value that UCKeyTranslate ignores and thus produces the correct value. Therefore, we were only seeing bugs in release modes where the uninitialized memory was a bad value (consistently 0x1 on my machine) causing the wrong key to come out. We were getting lucky before, this has always been a bug. --- src/apprt/embedded.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index bc1efc3ec..ac5a45259 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -557,7 +557,7 @@ pub const Surface = struct { // order to get the "unshifted_codepoint" for the key event. const unshifted_codepoint: u21 = unshifted: { var nomod_buf: [128]u8 = undefined; - var nomod_state: input.Keymap.State = undefined; + var nomod_state: input.Keymap.State = .{}; const nomod = try self.app.keymap.translate( &nomod_buf, &nomod_state,