From 597aac382b265a783ffb52f43647fcf13245133c Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Wed, 20 Feb 2019 16:36:30 +0100 Subject: [PATCH] Fix wrong bounds check in String::right --- core/ustring.cpp | 8 ++++---- 1 file 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)); }