From bd6fb8f172c49c89d3e71eaa84e982d60d72da4d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 29 Jun 2021 00:11:17 +0200 Subject: [PATCH] Fix issue when importing m4a PBD::RingBuffer<>::rw_vector can return a NULL pointer for the 2nd buffer, which can lead to undefined behavior: `memcpy (NULL, src, 0);` --- libs/ardour/ffmpegfileimportable.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/ardour/ffmpegfileimportable.cc b/libs/ardour/ffmpegfileimportable.cc index fe8d259acc..0727d0f88e 100644 --- a/libs/ardour/ffmpegfileimportable.cc +++ b/libs/ardour/ffmpegfileimportable.cc @@ -236,6 +236,9 @@ FFMPEGFileImportableSource::did_read_data (std::string data, size_t size) samplecnt_t written = 0; for (int i = 0; i < 2; ++i) { samplecnt_t cnt = std::min (n_samples, wv.len[i]); + if (!cnt || !wv.buf[i]) { + break; + } memcpy (wv.buf[i], cur, cnt * sizeof (float)); written += cnt; n_samples -= cnt;