Fixed crash in when MP3 length guesstimation failed

https://forum.zdoom.org/viewtopic.php?t=59881
This commit is contained in:
alexey.lysiuk 2018-03-20 18:01:35 +02:00
parent 6f68b6c352
commit f242f0631b
1 changed files with 2 additions and 1 deletions

View File

@ -298,8 +298,9 @@ SndFileSong::SndFileSong(FileReader &reader, SoundDecoder *decoder, uint32_t loo
if (!startass) loop_start = Scale(loop_start, SampleRate, 1000);
if (!endass) loop_end = Scale(loop_end, SampleRate, 1000);
const uint32_t sampleLength = (uint32_t)decoder->getSampleLength();
Loop_Start = loop_start;
Loop_End = clamp<uint32_t>(loop_end, 0, (uint32_t)decoder->getSampleLength());
Loop_End = sampleLength == 0 ? loop_end : clamp<uint32_t>(loop_end, 0, sampleLength);
Reader = std::move(reader);
Decoder = decoder;
Channels = iChannels == ChannelConfig_Stereo? 2:1;