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:
parent
25a3aeef86
commit
02c2018f25
|
@ -636,6 +636,9 @@ void ProjectFileDialog::removeSuppression()
|
||||||
{
|
{
|
||||||
const int row = mUI.mListSuppressions->currentRow();
|
const int row = mUI.mListSuppressions->currentRow();
|
||||||
QListWidgetItem *item = mUI.mListSuppressions->takeItem(row);
|
QListWidgetItem *item = mUI.mListSuppressions->takeItem(row);
|
||||||
|
if (!item)
|
||||||
|
return;
|
||||||
|
|
||||||
int suppressionIndex = getSuppressionIndex(item->text());
|
int suppressionIndex = getSuppressionIndex(item->text());
|
||||||
if (suppressionIndex >= 0)
|
if (suppressionIndex >= 0)
|
||||||
mSuppressions.removeAt(suppressionIndex);
|
mSuppressions.removeAt(suppressionIndex);
|
||||||
|
|
Loading…
Reference in New Issue