Fix crash when previewing projects with fewer than 6 audio channels;
authorCarl Hetherington <cth@carlh.net>
Thu, 4 Jun 2020 22:07:29 +0000 (00:07 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 4 Jun 2020 22:07:29 +0000 (00:07 +0200)
the old code tried to copy audio just because its channel had a non-0
value in the map without checking whether the destination channel
actually existed.

src/lib/util.cc

index e0efbc6f5254da21a9dc8d5801c1e8d2acf1746a..f9877523a0d3b4ef4b0ef56fc1163e866fb5f6fc 100644 (file)
@@ -823,7 +823,9 @@ remap (shared_ptr<const AudioBuffers> input, int output_channels, AudioMapping m
        shared_ptr<AudioBuffers> mapped (new AudioBuffers (output_channels, input->frames()));
        mapped->make_silent ();
 
-       for (int i = 0; i < map.input_channels(); ++i) {
+       int to_do = min (map.input_channels(), input->channels());
+
+       for (int i = 0; i < to_do; ++i) {
                for (int j = 0; j < mapped->channels(); ++j) {
                        if (map.get (i, static_cast<dcp::Channel> (j)) > 0) {
                                mapped->accumulate_channel (