Commit 15a1973e authored by Max Kellermann's avatar Max Kellermann

decoder/mad: fix integer underflow with very small files

When drop_start_samples and drop_end_samples overlap and are greater than the actual number of samples, the `num_samples` calculation in SubmitPCM() could underflow. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1712
parent ad7d47a8
ver 0.23.12 (not yet released)
* input
- curl: require CURL 7.55.0 or later
* decoder
- mad: fix integer underflow with very small files
* tags
- fix crash bug due to race condition
* output
......
......@@ -843,7 +843,7 @@ MadDecoder::SynthAndSubmit() noexcept
size_t pcm_length = synth.pcm.length;
if (drop_end_samples &&
current_frame == max_frames - drop_end_frames - 1) {
if (drop_end_samples >= pcm_length)
if (i + drop_end_samples >= pcm_length)
return DecoderCommand::STOP;
pcm_length -= drop_end_samples;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment