From e30ba8a8e0f1c182ae3ce7022667b7aca17d3df4 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 24 Oct 2020 14:43:32 -0700 Subject: cleanup: fix over-eager Coverity warnings Technically get_dive(i) could return a nullptr. But given the range for i that can never happen. Still, the test is extremely cheap and doesn't hurt. Fixes CID 354768 Fixes CID 354766 Signed-off-by: Dirk Hohndel --- qt-models/divetripmodel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'qt-models') diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index bc2c2ea46..6b700a92e 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -716,6 +716,8 @@ void DiveTripModelTree::populate() uiNotification(QObject::tr("start processing")); for (int i = 0; i < dive_table.nr; ++i) { dive *d = get_dive(i); + if (!d) // should never happen + continue; update_cylinder_related_info(d); if (d->hidden_by_filter) continue; @@ -1482,7 +1484,7 @@ void DiveTripModelList::populate() items.reserve(dive_table.nr); for (int i = 0; i < dive_table.nr; ++i) { dive *d = get_dive(i); - if (d->hidden_by_filter) + if (!d || d->hidden_by_filter) continue; items.push_back(d); } -- cgit v1.2.3-70-g09d2