From a41128c6adaf96b98ddfd8bca7af3ea825d51530 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Fri, 5 Jul 2013 11:46:49 -0700 Subject: [PATCH] Fixed divide by zero error in weird loop cases --- fb2k/in_vgmstream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fb2k/in_vgmstream.cpp b/fb2k/in_vgmstream.cpp index befbc311..62c386e5 100644 --- a/fb2k/in_vgmstream.cpp +++ b/fb2k/in_vgmstream.cpp @@ -195,7 +195,7 @@ void input_vgmstream::decode_seek(double p_seconds,abort_callback & p_abort) { int max_buffer_samples = sizeof(sample_buffer)/sizeof(sample_buffer[0])/vgmstream->channels; // adjust for correct position within loop - if(vgmstream->loop_flag && seek_pos_samples >= vgmstream->loop_end_sample) { + if(vgmstream->loop_flag && (vgmstream->loop_end_sample - vgmstream->loop_start_sample) && seek_pos_samples >= vgmstream->loop_end_sample) { seek_pos_samples -= vgmstream->loop_start_sample; seek_pos_samples %= (vgmstream->loop_end_sample - vgmstream->loop_start_sample); seek_pos_samples += vgmstream->loop_start_sample;