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<Iter>::operator* creates a temporary iterator which it then dereferences. This is a problem because what we are derefencing is a Gtk::TreeIter<Gtk::TreeRow>. 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 ().
This commit is contained in:
@@ -402,7 +402,7 @@ EditorSections::drag_data_received (Glib::RefPtr<Gdk::DragContext> 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";
|
||||
|
||||
Reference in New Issue
Block a user