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

Yordan Karadzhov <[email protected]> Sun, 19 Oct 2025 17:48:22 +0300
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
The patch is applied. Thanks!

Yordan

On 10/13/25 23:07, Mircea Cirjaliu wrote:
> 
> Pressing Ctrl+C with no data loaded will lead to a crash.
> Steps to reproduce:
> Click in the trace viewer window.
> Press Ctrl+C.
> 
> 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 {};
>   }