Browse Source

less: Fix out of bounds StringView indexing

This fixes indexing the StringView before knowing if the index
is valid. This did not crash until the changes from 13406b8
which added runtime checks for StringView indexing.
MacDue 3 years ago
parent
commit
9d0dccaa3f
1 changed files with 1 additions and 1 deletions
  1. 1 1
      Userland/Utilities/less.cpp

+ 1 - 1
Userland/Utilities/less.cpp

@@ -332,7 +332,7 @@ private:
 
 
     size_t render_status_line(StringView prompt, size_t off = 0, char end = '\0', bool ignored = false)
     size_t render_status_line(StringView prompt, size_t off = 0, char end = '\0', bool ignored = false)
     {
     {
-        for (; prompt[off] != end && off < prompt.length(); ++off) {
+        for (; off < prompt.length() && prompt[off] != end; ++off) {
             if (ignored)
             if (ignored)
                 continue;
                 continue;