Better assertion error in copy_from.
authorCarl Hetherington <cth@carlh.net>
Sun, 16 Feb 2020 21:05:49 +0000 (21:05 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 16 Feb 2020 21:28:25 +0000 (22:28 +0100)
src/lib/audio_buffers.cc

index 825c6c2f3219fa8bd6347d7aeddfc97fc005a29b..3692c304e148863a3dbc02a9f2805bb901c43648 100644 (file)
@@ -190,7 +190,12 @@ AudioBuffers::copy_from (AudioBuffers const * from, int32_t frames_to_copy, int3
 
        DCPOMATIC_ASSERT (from);
        DCPOMATIC_ASSERT (read_offset >= 0 && (read_offset + frames_to_copy) <= from->_allocated_frames);
-       DCPOMATIC_ASSERT (write_offset >= 0 && (write_offset + frames_to_copy) <= _allocated_frames);
+       if (write_offset < 0 || (write_offset + frames_to_copy) > _allocated_frames) {
+               throw ProgrammingError(
+                               __FILE__, __LINE__,
+                               String::compose("frames_to_copy=%1, read_offset=%2, write_offset=%3", frames_to_copy, read_offset, write_offset)
+                               );
+       }
 
        for (int i = 0; i < _channels; ++i) {
                memcpy (_data[i] + write_offset, from->_data[i] + read_offset, frames_to_copy * sizeof(float));