diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index 8262886ad6..5749e454c7 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -774,9 +774,11 @@ void TrimLeft(string &str, const char *s) void TrimRight(string &str, const char *s) { - int n = str.size()-1; - while(n >= 0 && strchr(s, str[n-1])) + int n = str.size(); + while(n > 0 && strchr(s, str[n-1])) n--; + /* Delete from n to the end. If n == str.size(), nothing is deleted; + * if n == 0, the whole string is erased. */ str.erase(str.begin()+n, str.end()); }