diff options
Diffstat (limited to 'src/liblzma/common')
-rw-r--r-- | src/liblzma/common/alone_decoder.c | 11 | ||||
-rw-r--r-- | src/liblzma/common/index_decoder.c | 10 | ||||
-rw-r--r-- | src/liblzma/common/stream_decoder.c | 11 |
3 files changed, 20 insertions, 12 deletions
diff --git a/src/liblzma/common/alone_decoder.c b/src/liblzma/common/alone_decoder.c index fa7fb839..039b4285 100644 --- a/src/liblzma/common/alone_decoder.c +++ b/src/liblzma/common/alone_decoder.c @@ -173,12 +173,15 @@ static lzma_ret alone_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit) { - if (new_memlimit != 0 && new_memlimit < coder->memusage) - return LZMA_MEMLIMIT_ERROR; - *memusage = coder->memusage; *old_memlimit = coder->memlimit; - coder->memlimit = new_memlimit; + + if (new_memlimit != 0) { + if (new_memlimit < coder->memusage) + return LZMA_MEMLIMIT_ERROR; + + coder->memlimit = new_memlimit; + } return LZMA_OK; } diff --git a/src/liblzma/common/index_decoder.c b/src/liblzma/common/index_decoder.c index a3ea791f..86a22971 100644 --- a/src/liblzma/common/index_decoder.c +++ b/src/liblzma/common/index_decoder.c @@ -219,12 +219,14 @@ index_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit) { *memusage = lzma_index_memusage(1, coder->count); + *old_memlimit = coder->memlimit; - if (new_memlimit != 0 && new_memlimit < *memusage) - return LZMA_MEMLIMIT_ERROR; + if (new_memlimit != 0) { + if (new_memlimit < *memusage) + return LZMA_MEMLIMIT_ERROR; - *old_memlimit = coder->memlimit; - coder->memlimit = new_memlimit; + coder->memlimit = new_memlimit; + } return LZMA_OK; } diff --git a/src/liblzma/common/stream_decoder.c b/src/liblzma/common/stream_decoder.c index 680fc53e..60cc8247 100644 --- a/src/liblzma/common/stream_decoder.c +++ b/src/liblzma/common/stream_decoder.c @@ -383,12 +383,15 @@ static lzma_ret stream_decoder_memconfig(lzma_coder *coder, uint64_t *memusage, uint64_t *old_memlimit, uint64_t new_memlimit) { - if (new_memlimit != 0 && new_memlimit < coder->memusage) - return LZMA_MEMLIMIT_ERROR; - *memusage = coder->memusage; *old_memlimit = coder->memlimit; - coder->memlimit = new_memlimit; + + if (new_memlimit != 0) { + if (new_memlimit < coder->memusage) + return LZMA_MEMLIMIT_ERROR; + + coder->memlimit = new_memlimit; + } return LZMA_OK; } |