summaryrefslogtreecommitdiffstats
path: root/core/string
diff options
context:
space:
mode:
authorClay John <claynjohn@gmail.com>2024-10-24 19:41:43 -0700
committerGitHub <noreply@github.com>2024-10-24 19:41:43 -0700
commit33db59094729c15ce4802154b2649bc8dd18a449 (patch)
treea687c42e27347c429fdef9dff25c933256490a45 /core/string
parenta1c7998d5f1adb084d14c667c68a61dab0a368f1 (diff)
parentb3b24ded19d5aeb015ab6633b2234f8c27b7c53e (diff)
downloadredot-engine-33db59094729c15ce4802154b2649bc8dd18a449.tar.gz
Merge pull request #98357 from yeojunh/valid-base-check-num-int64-uint64
Core: Fix String::num_int64(), uint64 for valid base check
Diffstat (limited to 'core/string')
-rw-r--r--core/string/ustring.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index e6f7492a18..4e9eb922f6 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -1850,6 +1850,8 @@ String String::num(double p_num, int p_decimals) {
}
String String::num_int64(int64_t p_num, int base, bool capitalize_hex) {
+ ERR_FAIL_COND_V_MSG(base < 2 || base > 36, "", "Cannot convert to base " + itos(base) + ", since the value is " + (base < 2 ? "less than 2." : "greater than 36."));
+
bool sign = p_num < 0;
int64_t n = p_num;
@@ -1888,6 +1890,8 @@ String String::num_int64(int64_t p_num, int base, bool capitalize_hex) {
}
String String::num_uint64(uint64_t p_num, int base, bool capitalize_hex) {
+ ERR_FAIL_COND_V_MSG(base < 2 || base > 36, "", "Cannot convert to base " + itos(base) + ", since the value is " + (base < 2 ? "less than 2." : "greater than 36."));
+
uint64_t n = p_num;
int chars = 0;