summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-02-20 17:48:53 +0100
committerGitHub <noreply@github.com>2019-02-20 17:48:53 +0100
commit5023cc111b96cea6cb8164bf56b6de75d656b75d (patch)
treefbb7e44a0eff651606bf0877b1b21b3c74ccfb1b
parent6d0ec870e3bca69be3f103bfdfc0b1dd726ef97c (diff)
parent597aac382b265a783ffb52f43647fcf13245133c (diff)
Merge pull request #26095 from lupoDharkael/right-left
Fix wrong bounds check in String::right
-rw-r--r--core/ustring.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp
index c1888c87a7..838907419e 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -2945,12 +2945,12 @@ String String::left(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 "";
+ if (p_pos <= 0)
+ return *this;
+
return substr(p_pos, (length() - p_pos));
}