Repository navigation
Conversation
C's ZopfliCompress hits assert(0) for a format other than gzip, zlib or deflate, which aborts the process. The port returned an error that its compress helper turned into a silent no-op.
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.
Abort on an unknown output format in ZopfliCompress, as C does
Problem
ZopfliCompress(C, Rust) switches on the output format. C handles gzip, zlib and deflate, and for anything else asserts. The build has noNDEBUG, soassert(0)aborts the process. The port matches formats 0, 1 and 2 and for any other value returns an error, which its compress helper turns into a silent no-op: nothing is written and the call returns normally. For example, callingZopfliCompresswithoutput_type = 64:output_type64assert(0)fails, the process aborts (SIGABRT)Question
Which behaviour do we want: C's or the Rust port's? Specifically, for an output format C does not recognise, should
ZopfliCompressabort (like the C source), or return quietly without writing anything (like the Rust port)?This PR implements C's behaviour.
Fix
Rust_ZopfliCompress's unknown-format arm callsstd::process::abort()in place of returning an error:Replayed on the
output_type = 64record, before and after:Both sides now abort, and the divergence closes.
Downstream check. The normal path is untouched:
ZopfliGzipCompresson the repository'sREADMEgives the same 831-byte stream from the port before and after this patch, andgzip.decompressrestores the file. C's stream is also 831 bytes but differs in a few bytes, for a separate reason (#213).Notes for review: