瀏覽代碼

Fix crash when checking empty string for valid hex number

Andrii Doroshenko (Xrayez) 6 年之前
父節點
當前提交
c891cf32ca
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      core/ustring.cpp

+ 4 - 1
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++;