[3.2] Backport hex_to_int/bin_to_int zero check and C# changes

This commit is contained in:
Aaron Franke
2021-01-28 09:22:13 -05:00
parent bc90bcb65c
commit 226528097e
2 changed files with 54 additions and 11 deletions

View File

@ -1670,9 +1670,10 @@ String::String(const StrRange &p_range) {
}
int String::hex_to_int(bool p_with_prefix) const {
if (p_with_prefix && length() < 3)
int len = length();
if (len == 0 || (p_with_prefix && len < 3)) {
return 0;
}
const CharType *s = ptr();
@ -1755,9 +1756,10 @@ int64_t String::hex_to_int64(bool p_with_prefix) const {
}
int64_t String::bin_to_int64(bool p_with_prefix) const {
if (p_with_prefix && length() < 3)
int len = length();
if (len == 0 || (p_with_prefix && len < 3)) {
return 0;
}
const CharType *s = ptr();