[system/dolphin] src: dolphintabwidget: Do not crash in updateTabName() on an invalid tab index
Méven Car <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit f73a46ef24d27bbfe90164333a4ea24de09e9cd9 by Méven Car.
Committed on 10/08/2026 at 11:04.
Pushed by meven into branch 'master'.
dolphintabwidget: Do not crash in updateTabName() on an invalid tab index
updateTabName() dereferences tabPageAt(index), which is widget(index) and
returns nullptr for an out-of-range index. Two callers pass indexOf(page),
which returns -1 when the page is not in the tab widget, so in release builds
a null tabPageAt() was dereferenced and crashed.
Return early on a negative index. The assert stays so debug builds and tests
still surface the caller that passed a bad index.
M +3 -0 src/dolphintabwidget.cpp
https://invent.kde.org/system/dolphin/-/commit/f73a46ef24d27bbfe90164333a4ea24de09e9cd9
diff --git a/src/dolphintabwidget.cpp b/src/dolphintabwidget.cpp
index 7fbf10b190..2c88575795 100644
--- a/src/dolphintabwidget.cpp
+++ b/src/dolphintabwidget.cpp
@@ -125,6 +125,9 @@ void DolphinTabWidget::refreshViews()
void DolphinTabWidget::updateTabName(int index)
{
Q_ASSERT(index >= 0);
+ if (index < 0) {
+ return;
+ }
if (!tabPageAt(index)->customLabel().isEmpty()) {
QString name = tabPageAt(index)->customLabel();