[PATCH] kernelshark: make sure ksmodels index is valid before use

Mircea Cirjaliu <[email protected]> Sat, 11 Oct 2025 13:45:12 +0200
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
Pressing Ctrl+C with no data loaded will lead to a crash.

Signed-off-by: Mircea Cirjaliu <[email protected]>
---
  src/KsModels.cpp | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/KsModels.cpp b/src/KsModels.cpp
index c8a6ba3..cf4cfe9 100644
--- a/src/KsModels.cpp
+++ b/src/KsModels.cpp
@@ -309,7 +309,8 @@ QVariant KsViewModel::data(const QModelIndex &index, 
int role) const
      }

      if (role == Qt::DisplayRole)
-        return this->getValue(index.column(), index.row());
+        if (index.isValid())
+            return this->getValue(index.column(), index.row());

      return {};
  }
-- 
2.43.0