From 9d0dccaa3f0ea7ad8c50f74d8e8eee9308d5a524 Mon Sep 17 00:00:00 2001 From: MacDue Date: Wed, 27 Jul 2022 12:50:29 +0100 Subject: [PATCH] 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. --- Userland/Utilities/less.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Utilities/less.cpp b/Userland/Utilities/less.cpp index 458627ebbe5..f37c1d51f17 100644 --- a/Userland/Utilities/less.cpp +++ b/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) { - for (; prompt[off] != end && off < prompt.length(); ++off) { + for (; off < prompt.length() && prompt[off] != end; ++off) { if (ignored) continue;