From a7a6c2b5579a90e23fbba0322d843c3898765d56 Mon Sep 17 00:00:00 2001 From: "v.audacity" Date: Fri, 20 Jul 2012 03:31:10 +0000 Subject: [PATCH] See http://bugzilla.audacityteam.org/show_bug.cgi?id=528#c11 (P2). --- src/Envelope.cpp | 2 +- src/WaveTrack.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Envelope.cpp b/src/Envelope.cpp index 805e8e1f9..3f2b400b7 100644 --- a/src/Envelope.cpp +++ b/src/Envelope.cpp @@ -1105,7 +1105,7 @@ void Envelope::GetValues(double *buffer, int bufferLen, t += tstep; continue; } - // IF after after THEN last value + // IF after envelope THEN last value if (t >= mEnv[len - 1]->t) { buffer[b] = mEnv[len - 1]->val; t += tstep; diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 85cc08750..99655a60e 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -1758,9 +1758,16 @@ void WaveTrack::GetEnvelopeValues(double *buffer, int bufferLen, rt0 = clip->GetStartTime(); } - if (rt0+rlen*tstep > clip->GetEndTime()) + if (rt0 + rlen*tstep > clip->GetEndTime()) { - rlen = clip->GetEndSample() - clip->GetStartSample(); + int nClipLen = clip->GetEndSample() - clip->GetStartSample(); + + // This check prevents problem cited in http://bugzilla.audacityteam.org/show_bug.cgi?id=528#c11, + // Gale's cross_fade_out project, which was already corrupted by bug 528. + //vvvvv Should really be checked earlier, in reading the project, but that needs much more debugging, and + // this prevents the previous write past the buffer end, in clip->GetEnvelope() call. + if (nClipLen < rlen) + rlen = nClipLen; } clip->GetEnvelope()->GetValues(rbuf, rlen, rt0, tstep); }