[PR #12342] Don't crash when reading emoji input in utf8 #28998

Open
opened 2026-01-31 09:32:09 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/12342

State: closed
Merged: No


Summary of the Pull Request

In the two places we read input from the console input buffer, we were not accounting for the fact that unicode input might turn into more than two input records.

InputBuffer::Read tries to account for how big unicode characters will be when read as input events, and only returns as much input as will fit in the caller's buffer. However, we were using IsGlyphFullWidth to check if a glyph was wide. However, that's not always right. SplitToOem might make three chars out of a single key, like in the case of emoji in utf8.

PR Checklist

Validation Steps Performed

**Original Pull Request:** https://github.com/microsoft/terminal/pull/12342 **State:** closed **Merged:** No --- ## Summary of the Pull Request In the two places we read input from the console input buffer, we were not accounting for the fact that unicode input might turn into more than two input records. `InputBuffer::Read` tries to account for how big unicode characters will be when read as input events, and only returns as much input as _will_ fit in the caller's buffer. However, we were using `IsGlyphFullWidth` to check if a glyph was wide. However, that's not always right. `SplitToOem` might make three `char`s out of a single key, like in the case of emoji in utf8. ## PR Checklist * [x] Closes #8663 * [x] I work here * [x] Tests added/passed * [n/a] Requires documentation to be updated ## Validation Steps Performed * wrote tests * Confirmed that the sample in https://github.com/microsoft/terminal/issues/8663#issuecomment-904788661 no longer crashes
claunia added the pull-request label 2026-01-31 09:32:09 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28998