Procházet zdrojové kódy

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.
Sebastian Zaha před 2 roky
rodič
revize
05fc63932b
1 změnil soubory, kde provedl 2 přidání a 0 odebrání
  1. 2 0
      Ladybird/ConsoleWidget.cpp

+ 2 - 0
Ladybird/ConsoleWidget.cpp

@@ -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++;