Commit bfbc76f8 authored by David Reid's avatar David Reid

Try fixing a memory leak when initializing a decoder fails.

parent 4b23beb1
...@@ -43342,16 +43342,21 @@ static ma_result ma_decoder__preinit(ma_decoder_read_proc onRead, ma_decoder_see ...@@ -43342,16 +43342,21 @@ static ma_result ma_decoder__preinit(ma_decoder_read_proc onRead, ma_decoder_see
static ma_result ma_decoder__postinit(const ma_decoder_config* pConfig, ma_decoder* pDecoder) static ma_result ma_decoder__postinit(const ma_decoder_config* pConfig, ma_decoder* pDecoder)
{ {
ma_result result; ma_result result = MA_SUCCESS;
/* Basic validation in case the internal decoder supports different limits to miniaudio. */ /* Basic validation in case the internal decoder supports different limits to miniaudio. */
if (pDecoder->internalChannels < MA_MIN_CHANNELS || pDecoder->outputChannels < MA_MIN_CHANNELS || if (pDecoder->internalChannels < MA_MIN_CHANNELS || pDecoder->outputChannels < MA_MIN_CHANNELS ||
pDecoder->internalChannels > MA_MAX_CHANNELS || pDecoder->outputChannels > MA_MAX_CHANNELS) { pDecoder->internalChannels > MA_MAX_CHANNELS || pDecoder->outputChannels > MA_MAX_CHANNELS) {
return MA_INVALID_DATA; result = MA_INVALID_DATA;
}
if (result == MA_SUCCESS) {
result = ma_decoder__init_data_converter(pDecoder, pConfig);
} }
result = ma_decoder__init_data_converter(pDecoder, pConfig); /* If we failed post initialization we need to uninitialize the decoder before returning to prevent a memory leak. */
if (result != MA_SUCCESS) { if (result != MA_SUCCESS) {
ma_decoder_uninit(pDecoder);
return result; return result;
} }
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