From 57fa9994af613bf32835a47d3bb3de8514c90890 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 14 Jun 2015 18:10:40 -0300 Subject: [PATCH] Verify that the bit depth argument in love.sound.newSoundData is valid / supported. --- src/modules/sound/SoundData.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/modules/sound/SoundData.cpp b/src/modules/sound/SoundData.cpp index 5a6ff8aa5..c083eb4eb 100644 --- a/src/modules/sound/SoundData.cpp +++ b/src/modules/sound/SoundData.cpp @@ -41,6 +41,9 @@ SoundData::SoundData(Decoder *decoder) , bitDepth(0) , channels(0) { + if (decoder->getBitDepth() != 8 && decoder->getBitDepth() != 16) + throw love::Exception("Invalid bit depth: %d", decoder->getBitDepth()); + size_t bufferSize = 524288; // 0x80000 int decoded = decoder->decode(); @@ -117,7 +120,7 @@ void SoundData::load(int samples, int sampleRate, int bitDepth, int channels, vo if (sampleRate <= 0) throw love::Exception("Invalid sample rate: %d", sampleRate); - if (bitDepth <= 0) + if (bitDepth != 8 && bitDepth != 16) throw love::Exception("Invalid bit depth: %d", bitDepth); if (channels <= 0)