From 92691d84853875ee9bc8296309e5172210044c61 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Mon, 20 Nov 2017 21:25:46 -0500 Subject: [PATCH] Bug1784: Changed conditions for exceptions from Sequence... ... That for SetSamples was too strict, making needless errors in case of harmless zero-length clips. The one for Get was analogous to SetSamples. That for Delete was too lax. But reexamination shows the stricter condition to be satisfied in all calls. Sequence::Delete() can be reached only from WaveClip::Clear and WaveClip::ClearAndAddCutLine(), and all calls to those are in WaveTrack.cpp. --- src/Sequence.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Sequence.cpp b/src/Sequence.cpp index 9b2964ddc..2eafed2fc 100644 --- a/src/Sequence.cpp +++ b/src/Sequence.cpp @@ -1123,8 +1123,7 @@ bool Sequence::Get(samplePtr buffer, sampleFormat format, return len == 0; } - if (start < 0 || start > mNumSamples || - start + len > mNumSamples) { + if (start < 0 || start + len > mNumSamples) { if (mayThrow) THROW_INCONSISTENCY_EXCEPTION; ClearSamples( buffer, floatSample, 0, len ); @@ -1164,8 +1163,7 @@ void Sequence::SetSamples(samplePtr buffer, sampleFormat format, { const auto size = mBlock.size(); - if (start < 0 || start >= mNumSamples || - start + len > mNumSamples) + if (start < 0 || start + len > mNumSamples) THROW_INCONSISTENCY_EXCEPTION; size_t tempSize = mMaxSamples; @@ -1660,7 +1658,7 @@ void Sequence::Delete(sampleCount start, sampleCount len) if (len == 0) return; - if (len < 0 || start < 0 || start >= mNumSamples) + if (len < 0 || start < 0 || start + len > mNumSamples) THROW_INCONSISTENCY_EXCEPTION; //TODO: add a ref-deref mechanism to SeqBlock/BlockArray so we don't have to make this a critical section.