aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common/stream_decoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/liblzma/common/stream_decoder.c')
-rw-r--r--src/liblzma/common/stream_decoder.c11
1 files changed, 7 insertions, 4 deletions
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;
}