Assert that nobody calls IO::copy_to_output with empty bufs
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Fri, 8 Jul 2016 22:19:44 +0000 (00:19 +0200)
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Fri, 8 Jul 2016 23:21:27 +0000 (01:21 +0200)
IO::copy_to_output() crashed if there was no channel to copy from. Since
all callers seem to check before calling, just assert() that it is not
the case.

libs/ardour/io.cc

index 6d15d5847874acb0e42e8ae4efb3d56e2d716829..ab667815ccfd4523c568b8d3de5033bf39cb54fc 100644 (file)
@@ -1721,12 +1721,14 @@ IO::collect_input (BufferSet& bufs, pframes_t nframes, ChanCount offset)
 void
 IO::copy_to_outputs (BufferSet& bufs, DataType type, pframes_t nframes, framecnt_t offset)
 {
-       // Copy any buffers 1:1 to outputs
-
        PortSet::iterator o = _ports.begin(type);
        BufferSet::iterator i = bufs.begin(type);
        BufferSet::iterator prev = i;
 
+       assert(i != bufs.end(type)); // or second loop will crash
+
+       // Copy any buffers 1:1 to outputs
+
        while (i != bufs.end(type) && o != _ports.end (type)) {
                Buffer& port_buffer (o->get_buffer (nframes));
                port_buffer.read_from (*i, nframes, offset);