Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
...at is requested
Base branch:
dev.dev-0.12doesn't have this code.Summary
There are two bugs at the same check, and both need
encodingFormatto be set:ma_decoder_init_vfs()andma_decoder_init_vfs_w()have already opened the file when they get here, and they don't close it. With a limit of 32 handles,fopen()fails after 29 of these opens, and a valid file then fails to open withToo many open files.result, so it returnsMA_NO_BACKENDeven when a custom backend has just opened the data. The caller gets an error and the backend is leaked.ma_decoder_init(),ma_decoder_init_vfs()andma_decoder_init_vfs_w()all do this, so a custom backend can't be used through them withencodingFormatset.ma_decoder_init_file()andma_decoder_init_memory()have the check, and work.Both only happen when the caller sets
encodingFormatand calls these functions directly. The resource manager doesn't set it, andma_decoder_init_file()returns before it gets to the VFS.The fix
result != MA_SUCCESScheck in all three, the same asma_decoder_init_file()andma_decoder_init_memory(). A decoder from a custom backend now continues to post-initialization.The comment above the check already describes this: "If we get to this point and we still haven't found a decoder".
ma_decoder_init__internal()is also called byma_decoder_init_memory()and the VFS functions, but they only get there with no format requested, so onlyma_decoder_init()changes.Reproduction
The program opens files through a VFS that counts the files left open, with allocation callbacks that count the allocations left. It writes
format_test.wavandformat_test.binto the current directory. Run it from the root of the repository.Before, on 877ea4a:
After:
Built with
-fsanitize=address -g, the program reports1560 byte(s) leaked in 3 allocation(s)before, and nothing after. Those are the three custom backends.