From a949197264cb2b40ed65c47dc845f2dc4235b7e4 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 15 Oct 2025 23:16:00 +0100 Subject: [PATCH] Fix ef71ce0a9d: Crash when user enters a blank line in the console. (#14711) Crash caused by reading outside the bounds of string_view (though not the underlying buffer) --- src/console_gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/console_gui.cpp b/src/console_gui.cpp index db8831f259..06db00510f 100644 --- a/src/console_gui.cpp +++ b/src/console_gui.cpp @@ -453,7 +453,7 @@ void IConsoleClose() static std::optional IConsoleHistoryAdd(std::string_view cmd) { /* Strip all spaces at the begin */ - while (IsWhitespace(cmd[0])) cmd.remove_prefix(1); + while (!cmd.empty() && IsWhitespace(cmd[0])) cmd.remove_prefix(1); /* Do not put empty command in history */ if (cmd.empty()) return std::nullopt;