浏览代码

Fix wrong bounds check in String::right

lupoDharkael 6 年之前
父节点
当前提交
597aac382b
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 4 4
      core/ustring.cpp

+ 4 - 4
core/ustring.cpp

@@ -2945,12 +2945,12 @@ String String::left(int p_pos) const {
 
 
 String String::right(int p_pos) const {
 String String::right(int p_pos) const {
 
 
-	if (p_pos >= size())
-		return *this;
-
-	if (p_pos < 0)
+	if (p_pos >= length())
 		return "";
 		return "";
 
 
+	if (p_pos <= 0)
+		return *this;
+
 	return substr(p_pos, (length() - p_pos));
 	return substr(p_pos, (length() - p_pos));
 }
 }