summaryrefslogtreecommitdiffstats
path: root/core/string
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-03-24 01:21:12 +0100
committerRémi Verschelde <rverschelde@gmail.com>2024-03-24 01:21:12 +0100
commit8f9136963dc33349e8a87f915e214d371b2fb023 (patch)
tree8767ab2d0531c3b1a3ea4c826eada894cc784fd5 /core/string
parent6ccf425a6874b68486acb57a346fdf0b6b41c2ba (diff)
parent87fe71f52f12bfdecd6f4a1109504224797675d5 (diff)
downloadredot-engine-8f9136963dc33349e8a87f915e214d371b2fb023.tar.gz
Merge pull request #89671 from alesliehughes/string_underrun
Stop possible underrun when processing a string
Diffstat (limited to 'core/string')
-rw-r--r--core/string/ustring.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index dbc283946e..93a08fd8b5 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -1871,7 +1871,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) {
@@ -2148,7 +2148,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) {