mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-16 17:41:14 +01:00
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.
This commit is contained in:
@@ -1123,8 +1123,7 @@ bool Sequence::Get(samplePtr buffer, sampleFormat format,
|
|||||||
return len == 0;
|
return len == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start < 0 || start > mNumSamples ||
|
if (start < 0 || start + len > mNumSamples) {
|
||||||
start + len > mNumSamples) {
|
|
||||||
if (mayThrow)
|
if (mayThrow)
|
||||||
THROW_INCONSISTENCY_EXCEPTION;
|
THROW_INCONSISTENCY_EXCEPTION;
|
||||||
ClearSamples( buffer, floatSample, 0, len );
|
ClearSamples( buffer, floatSample, 0, len );
|
||||||
@@ -1164,8 +1163,7 @@ void Sequence::SetSamples(samplePtr buffer, sampleFormat format,
|
|||||||
{
|
{
|
||||||
const auto size = mBlock.size();
|
const auto size = mBlock.size();
|
||||||
|
|
||||||
if (start < 0 || start >= mNumSamples ||
|
if (start < 0 || start + len > mNumSamples)
|
||||||
start + len > mNumSamples)
|
|
||||||
THROW_INCONSISTENCY_EXCEPTION;
|
THROW_INCONSISTENCY_EXCEPTION;
|
||||||
|
|
||||||
size_t tempSize = mMaxSamples;
|
size_t tempSize = mMaxSamples;
|
||||||
@@ -1660,7 +1658,7 @@ void Sequence::Delete(sampleCount start, sampleCount len)
|
|||||||
if (len == 0)
|
if (len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (len < 0 || start < 0 || start >= mNumSamples)
|
if (len < 0 || start < 0 || start + len > mNumSamples)
|
||||||
THROW_INCONSISTENCY_EXCEPTION;
|
THROW_INCONSISTENCY_EXCEPTION;
|
||||||
|
|
||||||
//TODO: add a ref-deref mechanism to SeqBlock/BlockArray so we don't have to make this a critical section.
|
//TODO: add a ref-deref mechanism to SeqBlock/BlockArray so we don't have to make this a critical section.
|
||||||
|
|||||||
Reference in New Issue
Block a user