summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-10-21 19:37:11 +0200
committerGitHub <noreply@github.com>2021-10-21 19:37:11 +0200
commitb6f4f23a5ed0f7aa4bafd0123fc0545044bfab50 (patch)
tree7382acfafd8a595f0fbcf94c8e358832a32f7b06 /core
parent133c1eb0af4b65966b674203113bbf64a039980f (diff)
parent549a48ccc9aa0acd0c0b15f67b1aeae914936996 (diff)
Merge pull request #54078 from Rubonnek/add_hex_messages_master
Add error messages to `String::hex_to_int`, and accept capital X in prefix
Diffstat (limited to 'core')
-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 daeb7fbd17..b1e685651e 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -2137,7 +2137,7 @@ int64_t String::hex_to_int() const {
s++;
}
- if (len > 2 && s[0] == '0' && s[1] == 'x') {
+ if (len > 2 && s[0] == '0' && lower_case(s[1]) == 'x') {
s += 2;
}
@@ -2151,7 +2151,7 @@ int64_t String::hex_to_int() const {
} else if (c >= 'a' && c <= 'f') {
n = (c - 'a') + 10;
} else {
- return 0;
+ ERR_FAIL_COND_V_MSG(true, 0, "Invalid hexadecimal notation character \"" + chr(*s) + "\" in string \"" + *this + "\".");
}
// Check for overflow/underflow, with special case to ensure INT64_MIN does not result in error
bool overflow = ((hex > INT64_MAX / 16) && (sign == 1 || (sign == -1 && hex != (INT64_MAX >> 4) + 1))) || (sign == -1 && hex == (INT64_MAX >> 4) + 1 && c > '0');