mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
liblzma: Stream decoder: Fix restarting after LZMA_MEMLIMIT_ERROR.
If lzma_code() returns LZMA_MEMLIMIT_ERROR it is now possible to use lzma_memlimit_set() to increase the limit and continue decoding. This was supposed to work from the beginning but there was a bug. With other decoders (.lzma or threaded .xz) this already worked correctly.
This commit is contained in:
parent
2caa9580e5
commit
976f897bbb
1 changed files with 13 additions and 3 deletions
|
@ -18,7 +18,8 @@ typedef struct {
|
||||||
enum {
|
enum {
|
||||||
SEQ_STREAM_HEADER,
|
SEQ_STREAM_HEADER,
|
||||||
SEQ_BLOCK_HEADER,
|
SEQ_BLOCK_HEADER,
|
||||||
SEQ_BLOCK,
|
SEQ_BLOCK_INIT,
|
||||||
|
SEQ_BLOCK_RUN,
|
||||||
SEQ_INDEX,
|
SEQ_INDEX,
|
||||||
SEQ_STREAM_FOOTER,
|
SEQ_STREAM_FOOTER,
|
||||||
SEQ_STREAM_PADDING,
|
SEQ_STREAM_PADDING,
|
||||||
|
@ -185,6 +186,15 @@ stream_decode(void *coder_ptr, const lzma_allocator *allocator,
|
||||||
return LZMA_OK;
|
return LZMA_OK;
|
||||||
|
|
||||||
coder->pos = 0;
|
coder->pos = 0;
|
||||||
|
coder->sequence = SEQ_BLOCK_INIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fall through
|
||||||
|
|
||||||
|
case SEQ_BLOCK_INIT: {
|
||||||
|
// Checking memusage and doing the initialization needs
|
||||||
|
// its own sequence point because we need to be able to
|
||||||
|
// retry if we return LZMA_MEMLIMIT_ERROR.
|
||||||
|
|
||||||
// Version 1 is needed to support the .ignore_check option.
|
// Version 1 is needed to support the .ignore_check option.
|
||||||
coder->block_options.version = 1;
|
coder->block_options.version = 1;
|
||||||
|
@ -243,12 +253,12 @@ stream_decode(void *coder_ptr, const lzma_allocator *allocator,
|
||||||
if (ret != LZMA_OK)
|
if (ret != LZMA_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
coder->sequence = SEQ_BLOCK;
|
coder->sequence = SEQ_BLOCK_RUN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fall through
|
// Fall through
|
||||||
|
|
||||||
case SEQ_BLOCK: {
|
case SEQ_BLOCK_RUN: {
|
||||||
const lzma_ret ret = coder->block_decoder.code(
|
const lzma_ret ret = coder->block_decoder.code(
|
||||||
coder->block_decoder.coder, allocator,
|
coder->block_decoder.coder, allocator,
|
||||||
in, in_pos, in_size, out, out_pos, out_size,
|
in, in_pos, in_size, out, out_pos, out_size,
|
||||||
|
|
Loading…
Reference in a new issue