From 69bb371305b632e11161263dcd746fd8831d68a9 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Sat, 23 Jun 2007 02:43:42 +0000 Subject: [PATCH] make audio display not crash on no audio loaded (1 FPE fix, 1 NULL deref fix) Originally committed to SVN as r1294. --- aegisub/audio_display.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/aegisub/audio_display.cpp b/aegisub/audio_display.cpp index 27d5978a3..425e235d8 100644 --- a/aegisub/audio_display.cpp +++ b/aegisub/audio_display.cpp @@ -904,7 +904,7 @@ __int64 AudioDisplay::GetSampleAtX(int x) { ///////////////////////////////////////////////// // Gets the x coordinate corresponding to sample int AudioDisplay::GetXAtSample(__int64 n) { - return (n/samples)-Position; + return samples ? (n/samples)-Position : 0; } @@ -1838,6 +1838,9 @@ void AudioDisplay::OnSize(wxSizeEvent &event) { /////////////// // Timer event void AudioDisplay::OnUpdateTimer(wxTimerEvent &event) { + if (!origImage) + return; + // Get lock and check if it's OK if (player->GetMutex()) { wxMutexLocker locker(*player->GetMutex());