From d774535fe916c0a1382bbc3ac795c92e17b8d3d4 Mon Sep 17 00:00:00 2001 From: Franke Burgarino Date: Fri, 9 Jan 2026 14:19:29 -0600 Subject: [PATCH] Fix reverse iterator issue caught by ASAN This issue could be seen when dragging an arrangement marker beyond the bottom of the list in the right edge. IIUC, std::reverse_iterator::operator* creates a temporary iterator which it then dereferences. This is a problem because what we are derefencing is a Gtk::TreeIter. gtkmm documentation for Gtk::TreeIter< T >::operator* states, "The returned reference is implemented by casting from *this, and so the returned reference is only valid while this iter is." Additionally, cpp documentation for std::reverse_iterator states, "std::reverse_iterator does not work with iterators whose dereference returns a reference to a member of *this." We also are not advancing this iterator at all, so whether it is reverse or not is irrelevant (we just want the last one). Thus, *prev(rows.end ()) instead of *rows.rbegin (). --- gtk2_ardour/editor_sections.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk2_ardour/editor_sections.cc b/gtk2_ardour/editor_sections.cc index 59f7d46777..2ad70bafc3 100644 --- a/gtk2_ardour/editor_sections.cc +++ b/gtk2_ardour/editor_sections.cc @@ -402,7 +402,7 @@ EditorSections::drag_data_received (Glib::RefPtr const& contex /* paste at end */ TreeModel::Children rows = _model->children (); assert (!rows.empty ()); - Gtk::TreeModel::Row row = *rows.rbegin (); + Gtk::TreeModel::Row row = *prev(rows.end ()); to = row[_columns.end]; #ifndef NDEBUG cout << "EditorSections::drag_data_received - paste at end\n";