From bd55ab0ff0f012e355ac7b8bebe90704e1348040 Mon Sep 17 00:00:00 2001 From: "v.audacity" Date: Mon, 20 Aug 2012 03:08:15 +0000 Subject: [PATCH] failsafe against crash per http://bugzilla.audacityteam.org/show_bug.cgi?id=367#c12 --- src/TrackPanel.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/TrackPanel.cpp b/src/TrackPanel.cpp index 494ba9b11..2da905be5 100644 --- a/src/TrackPanel.cpp +++ b/src/TrackPanel.cpp @@ -2570,8 +2570,17 @@ void TrackPanel::HandleSlide(wxMouseEvent & event) if (mCapturedTrack->GetKind() == Track::Wave) // Should always be true here, but make sure. { WaveTrack* pWaveTrack = (WaveTrack*)mCapturedTrack; - mCapturedClipArray[i].clip->Resample(pWaveTrack->GetRate()); - mCapturedClipArray[i].clip->MarkChanged(); + WaveClip* pWaveClip = mCapturedClipArray[i].clip; + //vvvvv FIX-ME: I think that at this point, mCapturedClipArray has + // the wrong clips if we're dragging a clip to another track, per bug 367. + // Probably, mCapturedClipArray does not match mCapturedTrack. + // Then if the mCapturedClipArray.GetCount() is wrong, pWaveClip can be NULL. + // This conditional is just a failsafe against crash on NULL deref. + if (pWaveClip) + { + pWaveClip->Resample(pWaveTrack->GetRate()); + pWaveClip->MarkChanged(); + } } SetCapturedTrack( NULL );