diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc index 03d24b649d..6eb4b552bb 100644 --- a/libs/ardour/bundle.cc +++ b/libs/ardour/bundle.cc @@ -676,10 +676,12 @@ Bundle::overall_channel_to_type (DataType t, uint32_t c) const Glib::Threads::Mutex::Lock lm (_channel_mutex); + assert (_channel.size () > c); + uint32_t s = 0; vector::const_iterator i = _channel.begin (); - for (uint32_t j = 0; j < c; ++j) { + for (uint32_t j = 0; j < c && i != _channel.end (); ++j) { if (i->type == t) { ++s; }