From e26edc93d6fb2d2586bcf989fca4308170f50bc3 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 16 Apr 2025 04:53:26 +0200 Subject: [PATCH] Fix crash when changing DPI while a marker is selected ~LocationMarkers() emits CatchDeletion, which calls Selection::remove(ArdourMarker*) which in turn calls Editor::marker_selection_changed(), which can cause a heap-use-after-free. So we first need to clear the location_markers map, before deleting the markers. --- gtk2_ardour/editor_markers.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 6f3849638d..92aa3a097a 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -66,14 +66,16 @@ using namespace Temporal; void Editor::clear_marker_display () { - for (LocationMarkerMap::iterator i = location_markers.begin(); i != location_markers.end(); ++i) { - delete i->second; - } - entered_marker = 0; + LocationMarkerMap lm = location_markers; location_markers.clear (); _sorted_marker_lists.clear (); + + for (auto const & [l, m] : lm ) { + delete m; + } + } void