Prevent endless read of silent files
authorRobin Gareus <robin@gareus.org>
Wed, 5 Dec 2018 15:04:29 +0000 (16:04 +0100)
committerRobin Gareus <robin@gareus.org>
Wed, 5 Dec 2018 15:04:29 +0000 (16:04 +0100)
This fixes issues with analysis and archiving that rely on a readable
to return 0.

Note however that createSilent() uses max_samplecnt (INT64_MAX) by
default. This relies on a region setting the length of its missing
source.

libs/ardour/ardour/silentfilesource.h

index a0bd51cc38c87ac107a739e97815514f8df6664f..79dc8b0a50d48e88aaa92302c946e267fe89f218 100644 (file)
@@ -51,7 +51,8 @@ protected:
                _length = len;
        }
 
-       samplecnt_t read_unlocked (Sample *dst, samplepos_t /*start*/, samplecnt_t cnt) const {
+       samplecnt_t read_unlocked (Sample *dst, samplepos_t start, samplecnt_t cnt) const {
+               cnt = std::min (cnt, _length - start);
                memset (dst, 0, sizeof (Sample) * cnt);
                return cnt;
        }