diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-02-20 17:48:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-20 17:48:53 +0100 |
commit | 5023cc111b96cea6cb8164bf56b6de75d656b75d (patch) | |
tree | fbb7e44a0eff651606bf0877b1b21b3c74ccfb1b | |
parent | 6d0ec870e3bca69be3f103bfdfc0b1dd726ef97c (diff) | |
parent | 597aac382b265a783ffb52f43647fcf13245133c (diff) |
Merge pull request #26095 from lupoDharkael/right-left
Fix wrong bounds check in String::right
-rw-r--r-- | core/ustring.cpp | 8 |
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)); } |