From e84071395a197a319f7ad62ee48b6a4906b92f79 Mon Sep 17 00:00:00 2001 From: Rodrigo Braz Monteiro Date: Fri, 18 Jan 2008 18:35:55 +0000 Subject: [PATCH] Fixed a crash in spectrum analyzer. Originally committed to SVN as r1767. --- aegisub/audio_spectrum.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aegisub/audio_spectrum.cpp b/aegisub/audio_spectrum.cpp index 28234b340..21cc47951 100644 --- a/aegisub/audio_spectrum.cpp +++ b/aegisub/audio_spectrum.cpp @@ -576,8 +576,8 @@ void AudioSpectrum::RenderRange(int64_t range_start, int64_t range_end, bool sel // Iterate over pixels, picking a range of samples for each for (int y = 0; y < imgheight; ++y) { - int sample1 = maxband * y/imgheight + minband; - int sample2 = maxband * (y+1)/imgheight + minband; + int sample1 = MAX(0,maxband * y/imgheight + minband); + int sample2 = MIN(signed(line_length),maxband * (y+1)/imgheight + minband); float maxval = 0; for (int samp = sample1; samp <= sample2; samp++) { if (power[samp] > maxval) maxval = power[samp];