aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2017-03-30 18:58:18 +0300
committerLasse Collin <lasse.collin@tukaani.org>2017-03-30 19:10:55 +0300
commitcbc74017939690d13441b8926bb743fb03211b83 (patch)
tree7460d31d2376db046f1ece2067c0da85a13dd88d /src/liblzma/common
parentUpdate NEWS for 5.2.3. (diff)
downloadxz-cbc74017939690d13441b8926bb743fb03211b83.tar.xz
liblzma: Fix handling of memlimit == 0 in lzma_index_decoder().
It returned LZMA_PROG_ERROR, which was done to avoid zero as the limit (because it's a special value elsewhere), but using LZMA_PROG_ERROR is simply inconvenient and can cause bugs. The fix/workaround is to treat 0 as if it were 1 byte. It's effectively the same thing. The only weird consequence is that then lzma_memlimit_get() will return 1 even when 0 was specified as the limit. This fixes a very rare corner case in xz --list where a specific memory usage limit and a multi-stream file could print the error message "Internal error (bug)" instead of saying that the memory usage limit is too low.
Diffstat (limited to 'src/liblzma/common')
-rw-r--r--src/liblzma/common/index_decoder.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/liblzma/common/index_decoder.c b/src/liblzma/common/index_decoder.c
index 1e33f0b0..cc07a1b8 100644
--- a/src/liblzma/common/index_decoder.c
+++ b/src/liblzma/common/index_decoder.c
@@ -256,7 +256,7 @@ index_decoder_reset(lzma_index_coder *coder, const lzma_allocator *allocator,
// Initialize the rest.
coder->sequence = SEQ_INDICATOR;
- coder->memlimit = memlimit;
+ coder->memlimit = my_max(1, memlimit);
coder->count = 0; // Needs to be initialized due to _memconfig().
coder->pos = 0;
coder->crc32 = 0;
@@ -271,7 +271,7 @@ index_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,
{
lzma_next_coder_init(&index_decoder_init, next, allocator);
- if (i == NULL || memlimit == 0)
+ if (i == NULL)
return LZMA_PROG_ERROR;
lzma_index_coder *coder = next->coder;