Commit da80018
Undefined-behaviour fix: safely call std::isspace in CompletionData (microsoft#5564)
### What was fixed
[CompletionData.cpp](cci:7://file:///c:/Users/T2430514/Downloads/winget-cli/src/AppInstallerCLICore/CompletionData.cpp:0:0-0:0)
passed a potentially negative `char` to `std::isspace`, invoking
undefined behaviour on non-ASCII input (signed `char` platforms). This
occasionally caused crashes or incorrect cursor repositioning when
autocompleting commands containing UTF-8 characters.
### How it was fixed
The character is now explicitly cast to `unsigned char` before the
`std::isspace` check:
```cpp
!std::isspace(static_cast<unsigned char>(commandLine[cursor - 1]))
```
This aligns with standard C++ guidance and makes the completion logic
robust across all locales.
###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/5564)
Co-authored-by: Odio Marcelino <[email protected]>1 parent 8115f41 commit da80018
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
0 commit comments