From: Soeren Apel Date: Fri, 3 Jul 2020 13:43:51 +0000 (+0200) Subject: TabularDecView: Prevent a race condition X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6f2f5d25db4f9a674ca25e5b74caf518ecd38ff6;p=pulseview.git TabularDecView: Prevent a race condition When it occurs, section is -1 and we'd throw an exception. Catch the case instead and simply ignore it. --- diff --git a/pv/views/tabular_decoder/model.cpp b/pv/views/tabular_decoder/model.cpp index b87bf058..d85bf6aa 100644 --- a/pv/views/tabular_decoder/model.cpp +++ b/pv/views/tabular_decoder/model.cpp @@ -164,8 +164,11 @@ uint8_t AnnotationCollectionModel::first_hidden_column() const QVariant AnnotationCollectionModel::headerData(int section, Qt::Orientation orientation, int role) const { + if ((section < 0) || (section >= (int)header_data_.size())) + return QVariant(); + if ((orientation == Qt::Horizontal) && (role == Qt::DisplayRole)) - return header_data_.at(section); + return header_data_[section]; return QVariant(); }