Prevent silentfile over-read #8563
Fixes negative read-count ``` Thread 45 (Thread 0x7fff9d79c640 (LWP 32440) "butler"): #0 ?? () from /lib64/libc.so.6 #1 ARDOUR::SilentFileSource::read_unlocked (this=0x5555699f2160, dst=0x7fff9c5d8010, start=60547072, cnt=-47406) at ../libs/ardour/ardour/silentfilesource.h:58 #2 ARDOUR::AudioSource::read (this=0x5555699f2160, dst=0x7fff9c5d8010, start=60547072, cnt=262144) at ../libs/ardour/audiosource.cc:322 #3 ARDOUR::AudioRegion::read_from_sources (this=0x555570859780, srcs=std::vector of length 2, capacity 2 = {...}, limit=33675720, buf=0x7fff9c5d8010, position=60547072, cnt=262144, chan_n=0) at ../libs/ardour/audioregion.cc:747 #4 ARDOUR::AudioRegion::read_at (this=0x555570859780, buf=0x7fff9cdd9010, mixdown_buffer=0x7fff9c5d8010, gain_buffer=0x7fff677ff010, position=60547072, cnt=262144, chan_n=0) at ../libs/ardour/audioregion.cc:587 ```
This commit is contained in:
@@ -54,7 +54,7 @@ protected:
|
||||
}
|
||||
|
||||
samplecnt_t read_unlocked (Sample *dst, samplepos_t start, samplecnt_t cnt) const {
|
||||
cnt = std::min (cnt, _length - start);
|
||||
cnt = std::min (cnt, std::max<samplecnt_t> (0, _length - start));
|
||||
memset (dst, 0, sizeof (Sample) * cnt);
|
||||
return cnt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user