From 831e0f7d1b5cdbce69cb5f722888a63117b730c6 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Wed, 27 Nov 2024 12:05:04 -0500 Subject: [PATCH] Add check to optional value to avoid undefined behavior in MarkerModel --- scwx-qt/source/scwx/qt/model/marker_model.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scwx-qt/source/scwx/qt/model/marker_model.cpp b/scwx-qt/source/scwx/qt/model/marker_model.cpp index 9bd057ea..e550312e 100644 --- a/scwx-qt/source/scwx/qt/model/marker_model.cpp +++ b/scwx-qt/source/scwx/qt/model/marker_model.cpp @@ -294,6 +294,10 @@ void MarkerModel::HandleMarkersInitialized(size_t count) void MarkerModel::HandleMarkerAdded(types::MarkerId id) { std::optional index = p->markerManager_->get_index(id); + if (!index) + { + return; + } const int newIndex = static_cast(*index); beginInsertRows(QModelIndex(), newIndex, newIndex);