From c90cf67dc6e4df584a55f51fe9fc39a41b2a6ab6 Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 10 Aug 2022 22:07:00 +0430 Subject: [PATCH] Shell: Avoid StringView OOB access in Formatter ctor --- Userland/Shell/Formatter.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Shell/Formatter.h b/Userland/Shell/Formatter.h index c6c4e3fb1a..1a08790cf2 100644 --- a/Userland/Shell/Formatter.h +++ b/Userland/Shell/Formatter.h @@ -24,6 +24,9 @@ public: , m_source(source) , m_cursor(cursor) { + if (m_source.is_empty()) + return; + size_t offset = 0; for (auto ptr = m_source.end() - 1; ptr >= m_source.begin() && isspace(*ptr); --ptr) ++offset;