From 051f49c52ea335e90eaf62f08428cec3104e8996 Mon Sep 17 00:00:00 2001 From: reuk Date: Tue, 17 Nov 2020 16:47:57 +0000 Subject: [PATCH] WAV: Fail gracefully on unsupported bit depths --- modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp index f25261c2ec..7642040bd9 100644 --- a/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_WavAudioFormat.cpp @@ -993,10 +993,12 @@ public: input->skipNextBytes (2); bitsPerSample = (unsigned int) (int) input->readShort(); - if (bitsPerSample > 64) + if (bitsPerSample > 64 && (int) sampleRate != 0) { bytesPerFrame = bytesPerSec / (int) sampleRate; - bitsPerSample = 8 * (unsigned int) bytesPerFrame / numChannels; + + if (numChannels != 0) + bitsPerSample = 8 * (unsigned int) bytesPerFrame / numChannels; } else {