[PR #16624] Fix a bug caused by #16592 #30963

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

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

State: closed
Merged: Yes


#16592 passes the return value of GetEnvironmentStringsW directly
to the hstring constructor even though the former returns a
double-null terminated string and the latter expects a regular one.

This PR fixes the issue by using a basic strlen() loop to compute
the length ourselves. It's still theoretically beneficial over
the previous code, but now it's rather bitter since the code isn't
particularly short anymore and so the biggest benefit is gone.

Closes #16623

Validation Steps Performed

  • Validated the env string in a debugger ✅
    It's 1 character shorter than the old til::env string.
    That's fine however, since any HSTRING is always null-terminated
    anyways and so we get an extra null-terminator for free.
  • wt powershell works ✅
**Original Pull Request:** https://github.com/microsoft/terminal/pull/16624 **State:** closed **Merged:** Yes --- #16592 passes the return value of `GetEnvironmentStringsW` directly to the `hstring` constructor even though the former returns a double-null terminated string and the latter expects a regular one. This PR fixes the issue by using a basic strlen() loop to compute the length ourselves. It's still theoretically beneficial over the previous code, but now it's rather bitter since the code isn't particularly short anymore and so the biggest benefit is gone. Closes #16623 ## Validation Steps Performed * Validated the `env` string in a debugger ✅ It's 1 character shorter than the old `til::env` string. That's fine however, since any `HSTRING` is always null-terminated anyways and so we get an extra null-terminator for free. * `wt powershell` works ✅
claunia added the pull-request label 2026-01-31 09:44:08 +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#30963