Handle WavpackUnpackSamples failure

This commit is contained in:
Robert Müller 2022-06-26 21:58:04 +02:00
parent a8949cb96b
commit 82425f20d7

View file

@ -533,7 +533,12 @@ int CSound::DecodeWV(int SampleID, const void *pData, unsigned DataSize)
}
int *pBuffer = (int *)calloc((size_t)NumSamples * NumChannels, sizeof(int));
WavpackUnpackSamples(pContext, pBuffer, NumSamples); // TODO: check return value
if(!WavpackUnpackSamples(pContext, pBuffer, NumSamples))
{
free(pBuffer);
dbg_msg("sound/wv", "WavpackUnpackSamples failed. NumSamples=%d, NumChannels=%d", NumSamples, NumChannels);
return -1;
}
int *pSrc = pBuffer;
pSample->m_pData = (short *)calloc((size_t)NumSamples * NumChannels, sizeof(short));