Skip to contentSkip to conversation

kernelshark: make sure ksmodels index is valid before use

PATCH In review Mircea Cirjaliu 2 participants 2 messages Oct 13, 2025 – Oct 19, 2025 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 kernelshark: make sure ksmodels index is valid before use

Pressing Ctrl+C with no data loaded will lead to a crash. Steps to reproduce:
Click in the trace viewer window.
Press Ctrl+C.

---
 src/KsModels.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/KsModels.cpp +2 -1
index c8a6ba3..cf4cfe9 100644
@@ -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 {};
 }
Signature · 1 line
2.43.0
#2 lore raw

The patch is applied. Thanks!

Yordan

Quoted 25 lines · Mircea Cirjaliu

Pressing Ctrl+C with no data loaded will lead to a crash. Steps to reproduce:
Click in the trace viewer window.
Press Ctrl+C.

---
  src/KsModels.cpp | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
src/KsModels.cpp +2 -1
index c8a6ba3..cf4cfe9 100644
@@ -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 {};
  }