diff --git a/codec/ALACDecoder.cpp b/codec/ALACDecoder.cpp index 7804728..c8f0d17 100644 --- a/codec/ALACDecoder.cpp +++ b/codec/ALACDecoder.cpp @@ -128,10 +128,13 @@ int32_t ALACDecoder::Init( void * inMagicCookie, uint32_t inMagicCookieSize ) theConfig.sampleRate = Swap32BtoN(((ALACSpecificConfig *)theActualCookie)->sampleRate); mConfig = theConfig; - + + //sanity checks RequireAction( mConfig.compatibleVersion <= kALACVersion, return kALAC_ParamError; ); + RequireAction( mConfig.bitDepth == 16 || mConfig.bitDepth == 20 || mConfig.bitDepth == 24 || mConfig.bitDepth == 32, return kALAC_ParamError; ); RequireAction( mConfig.frameLength > 0 && mConfig.frameLength <= 16384, return kALAC_ParamError; ); RequireAction( mConfig.sampleRate > 0 && mConfig.sampleRate <= 384000, return kALAC_ParamError; ); + RequireAction( mConfig.numChannels > 0 && mConfig.numChannels < kALACMaxChannels, return kALAC_ParamError; ); // allocate mix buffers mMixBufferU = (int32_t *) calloc( mConfig.frameLength * sizeof(int32_t), 1 );