Skip to content

Commit 02c2018

Browse files
elfringdanmar
authored andcommitted
Addition of a null pointer check in ProjectFileDialog::removeSuppression() (cppcheck-opensource#1457)
The function “QListWidget::takeItem” is documented in the way that a null pointer can be returned. This result was not checked by the function “ProjectFileDialog::removeSuppression” so far. Thus add a corresponding check so that an inappropriate pointer access should not happen any more here. Link: https://sourceforge.net/p/cppcheck/discussion/development/thread/d1d0b65245/#a1bf Link: https://trac.cppcheck.net/ticket/8814 Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
1 parent 25a3aee commit 02c2018

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎gui/projectfiledialog.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,9 @@ void ProjectFileDialog::removeSuppression()
636636
{
637637
const int row = mUI.mListSuppressions->currentRow();
638638
QListWidgetItem *item = mUI.mListSuppressions->takeItem(row);
639+
if (!item)
640+
return;
641+
639642
int suppressionIndex = getSuppressionIndex(item->text());
640643
if (suppressionIndex >= 0)
641644
mSuppressions.removeAt(suppressionIndex);

0 commit comments

Comments
 (0)