summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Doroshenko (Xrayez) <xrayez@gmail.com>2018-12-24 20:06:35 +0200
committerAndrii Doroshenko (Xrayez) <xrayez@gmail.com>2018-12-24 20:06:35 +0200
commitc891cf32caacb9f449b117fbb984e280d1a60ba5 (patch)
tree4c9b42a534504a1f6fb485e4b23866684b35417b
parent10e9221c49eddc05cb36c0b582060cac9e4c8cef (diff)
Fix crash when checking empty string for valid hex number
-rw-r--r--core/ustring.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 083a1eaed6..d8b804d484 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -3578,9 +3578,12 @@ bool String::is_valid_integer() const {
bool String::is_valid_hex_number(bool p_with_prefix) const {
- int from = 0;
int len = length();
+ if (len == 0)
+ return false;
+
+ int from = 0;
if (len != 1 && (operator[](0) == '+' || operator[](0) == '-'))
from++;