mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
liblzma: Use LZMA1EXT feature in lzma_alone_decoder().
This avoids the need to use the slightly ugly method to set the uncompressed size.
This commit is contained in:
parent
33b8a24b66
commit
e310e8b6a4
1 changed files with 13 additions and 5 deletions
|
@ -110,12 +110,24 @@ alone_decode(void *coder_ptr, const lzma_allocator *allocator,
|
|||
// Another hack to ditch false positives: Assume that
|
||||
// if the uncompressed size is known, it must be less
|
||||
// than 256 GiB.
|
||||
//
|
||||
// FIXME? Without picky we allow > LZMA_VLI_MAX which doesn't
|
||||
// really matter in this specific situation (> LZMA_VLI_MAX is
|
||||
// safe in the LZMA decoder) but it's somewhat weird still.
|
||||
if (coder->picky
|
||||
&& coder->uncompressed_size != LZMA_VLI_UNKNOWN
|
||||
&& coder->uncompressed_size
|
||||
>= (LZMA_VLI_C(1) << 38))
|
||||
return LZMA_FORMAT_ERROR;
|
||||
|
||||
// Use LZMA_FILTER_LZMA1EXT features to specify the
|
||||
// uncompressed size and that the end marker is allowed
|
||||
// even when the uncompressed size is known. Both .lzma
|
||||
// header and LZMA1EXT use UINT64_MAX indicate that size
|
||||
// is unknown.
|
||||
coder->options.ext_flags = LZMA_LZMA1EXT_ALLOW_EOPM;
|
||||
lzma_set_ext_size(coder->options, coder->uncompressed_size);
|
||||
|
||||
// Calculate the memory usage so that it is ready
|
||||
// for SEQ_CODER_INIT.
|
||||
coder->memusage = lzma_lzma_decoder_memusage(&coder->options)
|
||||
|
@ -132,7 +144,7 @@ alone_decode(void *coder_ptr, const lzma_allocator *allocator,
|
|||
|
||||
lzma_filter_info filters[2] = {
|
||||
{
|
||||
.id = LZMA_FILTER_LZMA1,
|
||||
.id = LZMA_FILTER_LZMA1EXT,
|
||||
.init = &lzma_lzma_decoder_init,
|
||||
.options = &coder->options,
|
||||
}, {
|
||||
|
@ -143,10 +155,6 @@ alone_decode(void *coder_ptr, const lzma_allocator *allocator,
|
|||
return_if_error(lzma_next_filter_init(&coder->next,
|
||||
allocator, filters));
|
||||
|
||||
// Use a hack to set the uncompressed size.
|
||||
lzma_lz_decoder_uncompressed(coder->next.coder,
|
||||
coder->uncompressed_size, true);
|
||||
|
||||
coder->sequence = SEQ_CODE;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue