diff --git a/app/render/backend/audio/audiobackend.cpp b/app/render/backend/audio/audiobackend.cpp index 4336ceff4..0521d75a5 100644 --- a/app/render/backend/audio/audiobackend.cpp +++ b/app/render/backend/audio/audiobackend.cpp @@ -68,7 +68,14 @@ void AudioBackend::ThreadCompletedCache(NodeDependency dep) } // Replace data with this data - memcpy(pcm_data_.data() + offset, cached_samples.data(), static_cast(length)); + int copy_length = qMin(length, cached_samples.size()); + + memcpy(pcm_data_.data() + offset, cached_samples.data(), static_cast(copy_length)); + + if (copy_length < length) { + // Fill in remainder with silence + memset(pcm_data_.data() + offset + copy_length, 0, static_cast(length - copy_length)); + } QFile f(CachePathName()); if (f.open(QFile::WriteOnly)) {