Skip to contentSkip to conversation

kernelshark: make sure ksmodels index is valid before use

PATCH In review Mircea Cirjaliu 2 participants 2 messages Oct 11, 2025 – Oct 12, 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.

---
 src/KsModels.cpp | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)
src/KsModels.cpp +0 -0
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

Hi Mircea,

There are two issues with this patch.

First, please provide more detailed instruction how to reproduce the problem, because I tried "Pressing Ctrl+C with no data loaded" and I see no crash. Nevertheless, the change you suggest looks like a valid fix to me.

The second issue is that the patch itself fails to apply.
My guess is that your Yahoo mail server is messing the text encoding of the patch resulting in git rejecting it.

Cheers,
Yordan

Quoted 22 lines · Mircea Cirjaliu

Pressing Ctrl+C with no data loaded will lead to a crash.

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