diff --git a/src/plugins/debugger/stackwindow.cpp b/src/plugins/debugger/stackwindow.cpp
index f5720e2644595888e35087e3f384901d0c17f04d..007fe9758b240c0ddd42240f1c4170bab76fd9d9 100644
--- a/src/plugins/debugger/stackwindow.cpp
+++ b/src/plugins/debugger/stackwindow.cpp
@@ -102,7 +102,7 @@ void StackWindow::contextMenuEvent(QContextMenuEvent *ev)
     const int row = index.row();
     const unsigned engineCapabilities = engine->debuggerCapabilities();
     StackFrame frame;
-    if (row < handler->stackSize())
+    if (row >= 0 && row < handler->stackSize())
         frame = handler->frameAt(row);
     const quint64 address = frame.address;