Commit 8234df87 authored by David Reid's avatar David Reid

Fix a possible double file close when decoder initialization fails.

Public issue https://github.com/mackron/miniaudio/issues/319
parent a10e7636
......@@ -48127,7 +48127,10 @@ MA_API ma_result ma_decoder_init_vfs(ma_vfs* pVFS, const char* pFilePath, const
}
if (result != MA_SUCCESS) {
ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
if (pDecoder->backend.vfs.file != NULL) { /* <-- Will be reset to NULL if ma_decoder_uninit() is called in one of the steps above which allows us to avoid a double close of the file. */
ma_vfs_or_default_close(pVFS, pDecoder->backend.vfs.file);
}
return result;
}
......@@ -48528,6 +48531,7 @@ MA_API ma_result ma_decoder_uninit(ma_decoder* pDecoder)
if (pDecoder->onRead == ma_decoder__on_read_vfs) {
ma_vfs_or_default_close(pDecoder->backend.vfs.pVFS, pDecoder->backend.vfs.file);
pDecoder->backend.vfs.file = NULL;
}
ma_data_converter_uninit(&pDecoder->converter);
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