summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2020-04-22 22:37:43 +0200
committerRobin Gareus <robin@gareus.org>2020-04-22 22:37:43 +0200
commit485ac454771a7ae5301524f9ba0a5adb28fbacf4 (patch)
treef9a514f4893c402a7f525f28bc39984c3d0c4723 /gtk2_ardour
parentea16fc51d328cdf1fc58972858cbc490f3fa3afa (diff)
Fix region boundary cache lookup segfault
When the cursor position is after the last item in the vector, upper_bound returns the last given iterator, here: `region_boundary_cache.end()`, which is invalid to dereference. Furthermore prevent possible duplicate prev/next pair at zero, when using the video-timelime.
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/editor.cc3
-rw-r--r--gtk2_ardour/editor_ops.cc7
2 files changed, 8 insertions, 2 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index a6b5a34d49..584a007302 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -2995,6 +2995,9 @@ Editor::snap_to_internal (MusicSample& start, RoundMode direction, SnapPref pref
prev = next;
prev--;
}
+ if (next == region_boundary_cache.end ()) {
+ next--;
+ }
if ((direction == RoundUpMaybe || direction == RoundUpAlways)) {
test = *next;
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index ead64e378d..2c0d3bcdee 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -768,9 +768,12 @@ Editor::build_region_boundary_cache ()
}
}
- //allow regions to snap to the video start (if any) as if it were a "region"
+ /* allow regions to snap to the video start (if any) as if it were a "region" */
if (ARDOUR_UI::instance()->video_timeline) {
- region_boundary_cache.push_back (ARDOUR_UI::instance()->video_timeline->get_video_start_offset());
+ ARDOUR::samplepos_t vo = ARDOUR_UI::instance()->video_timeline->get_video_start_offset();
+ if (std::find (region_boundary_cache.begin(), region_boundary_cache.end(), vo) == region_boundary_cache.end()) {
+ region_boundary_cache.push_back (ARDOUR_UI::instance()->video_timeline->get_video_start_offset());
+ }
}
std::pair<samplepos_t, samplepos_t> ext = session_gui_extents (false);