From 2fd0cd4ea1ef32e048101e1053b729b2ca63d00c Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 30 Mar 2021 14:03:50 -0700 Subject: [PATCH] selection: prevent use after free crash This is hiding a bigger issue in the way changes are propagated through the code, but it should stop an annoying crash in 5.0 from happening. Signed-off-by: Dirk Hohndel --- stats/statsview.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stats/statsview.cpp b/stats/statsview.cpp index 148611cfc..d6ebe6520 100644 --- a/stats/statsview.cpp +++ b/stats/statsview.cpp @@ -377,6 +377,9 @@ void StatsView::replotIfVisible() void StatsView::divesSelected(const QVector &dives) { + if (dive_table.nr <= 0) + // there are no dives, don't bother (this can happen during reset, for example) + return; if (isVisible()) { for (auto &series: series) series->divesSelected(dives);