Repository navigation
Conversation
FLAC__stream_decoder_reset() is documented to leave the state unchanged when the rewind fails, but it flushed the decoder and reset the Ogg layer before calling the seek callback. After a failed reset, the buffered input had been discarded, the state had changed and MD5 checking was off. Fixes xiph#958
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.
When the rewind in
FLAC__stream_decoder_reset()fails (the seek callback returnsFLAC__STREAM_DECODER_SEEK_STATUS_ERROR), the function should returnfalsewith the state unchanged, as documented in stream_decoder.h. It does returnfalse, but it has already flushed the decoder and reset the Ogg layer by then: the buffered input is gone, the state has changed and MD5 checking is off.This moves the rewind in front of the flush. Nothing else changes: an uninitialized decoder, or one in
FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR, still fails without calling the seek callback, and the call from init still doesn't rewind.Tested on master (59fa340), ASan+UBSan build, with the program from #958, seek callback failing once at the rewind:
reset()returnedfalsereset()callSEARCH_FOR_FRAME_SYNCEND_OF_STREAMEND_OF_STREAMThe test suite (
ctest, 10 tests) passes in the default,WITH_OGG=OFF,WITH_ASM=OFF,ENABLE_64_BIT_WORDS=OFFandFLAC__INTEGER_ONLY_LIBRARYbuilds.Fixes #958