Addition of a null pointer check in ProjectFileDialog::removeSuppression() (#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>
This commit is contained in:
Markus Elfring 2018-10-29 14:21:56 +01:00 committed by Daniel Marjamäki
parent 25a3aeef86
commit 02c2018f25
1 changed files with 3 additions and 0 deletions

View File

@ -636,6 +636,9 @@ void ProjectFileDialog::removeSuppression()
{
const int row = mUI.mListSuppressions->currentRow();
QListWidgetItem *item = mUI.mListSuppressions->takeItem(row);
if (!item)
return;
int suppressionIndex = getSuppressionIndex(item->text());
if (suppressionIndex >= 0)
mSuppressions.removeAt(suppressionIndex);