Repository navigation
fix(input): stop startup heap corruption from an undersized Raw Input device-name buffer - #1
Merged
E4crypt3d merged 2 commits intoSep 6, 2026
Conversation
…ecause the raw-input device-name buffer was sized in bytes while Windows measures and writes that name in characters
E4crypt3d
pushed a commit
that referenced
this pull request
Sep 6, 2026
…flow fix(input): stop startup heap corruption from an undersized Raw Input device-name buffer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
The app crashes with
0xC0000374(heap corruption) shortly after startup — sometimes instantly, sometimes a minute or two in. Earlier fixes treated symptoms (panic hook,catch_unwind,--disable-gpu-compositing); the real defect is indevices.rs::device_path.GetRawInputDeviceInfoW's size query reports the device-name buffer size in WCHARs on current Windows, and the follow-up call writes the entire null-terminated name regardless of the size passed in. The code allocatedsize/2 + 4WCHARs (~half the needed space), so every enumerated keyboard overflowed its heap block by roughly half the name length — silent memory corruption on every launch.Verified with a canary probe against a real device list: the old allocation clobbered the guard region after the buffer on all devices; the corrected allocation (
size + 1WCHARs, safe under every bytes-vs-WCHARs interpretation) does not.Fix
src-tauri/src/input/devices.rs— size the device-name buffer in characters (size + 1WCHARs) instead of bytes.Verification
cdbwith the Windows debug heap (which crashed the old binary in <2 s, 3/3 runs): 75 s clean run, no heap corruption, full UI up.cargo test: 29 passed, 0 failed.Release
Also bumps the app to 0.3.7 (
Cargo.toml,tauri.conf.json,package.json,Cargo.lock) and adds the CHANGELOG entry. Merging triggers the automatic v0.3.7 release build perrelease.yml.