mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-07-04 23:31:19 +01:00
string_util: Prevent out of bounds access in u16string_view buffer
This commit is contained in:
parent
44c73cfca0
commit
3ffff78a27
1 changed files with 2 additions and 2 deletions
|
@ -191,9 +191,9 @@ std::string StringFromFixedZeroTerminatedBuffer(const char* buffer, std::size_t
|
|||
std::u16string UTF16StringFromFixedZeroTerminatedBuffer(std::u16string_view buffer,
|
||||
std::size_t max_len) {
|
||||
std::size_t len = 0;
|
||||
while (len < max_len && buffer[len] != '\0')
|
||||
while (len < buffer.length() && len < max_len && buffer[len] != '\0') {
|
||||
++len;
|
||||
|
||||
}
|
||||
return std::u16string(buffer.begin(), buffer.begin() + len);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue