Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop possible underrun when processing a string #89671

Merged
1 commit merged into from
Mar 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/string/ustring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1822,7 +1822,7 @@ Error String::parse_utf8(const char *p_utf8, int p_len, bool p_skip_cr) {
bool decode_failed = false;
{
const char *ptrtmp = p_utf8;
const char *ptrtmp_limit = &p_utf8[p_len];
const char *ptrtmp_limit = p_len >= 0 ? &p_utf8[p_len] : nullptr;
int skip = 0;
uint8_t c_start = 0;
while (ptrtmp != ptrtmp_limit && *ptrtmp) {
Expand Down Expand Up @@ -2099,7 +2099,7 @@ Error String::parse_utf16(const char16_t *p_utf16, int p_len) {
bool decode_error = false;
{
const char16_t *ptrtmp = p_utf16;
const char16_t *ptrtmp_limit = &p_utf16[p_len];
const char16_t *ptrtmp_limit = p_len >= 0 ? &p_utf16[p_len] : nullptr;
uint32_t c_prev = 0;
bool skip = false;
while (ptrtmp != ptrtmp_limit && *ptrtmp) {
Expand Down
Loading