1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:17:34 +00:00

Ladybird: Fix JS console crash when history is empty

Do not try to navigate JS console history forward when it is empty. A
crash was occurring because of size_t underflow.
This commit is contained in:
Sebastian Zaha 2023-07-31 23:07:49 +02:00 committed by Andreas Kling
parent cd0fe4bb48
commit 05fc63932b

View file

@ -175,6 +175,8 @@ void ConsoleInputEdit::keyPressEvent(QKeyEvent* event)
{
switch (event->key()) {
case Qt::Key_Down: {
if (m_history.is_empty())
break;
auto last_index = m_history.size() - 1;
if (m_history_index < last_index) {
m_history_index++;