aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2010-01-01 00:29:10 +0200
committerLasse Collin <lasse.collin@tukaani.org>2010-01-01 00:29:10 +0200
commit8ea8dc754a7a5bc2d60db1eac201839cabdab6a1 (patch)
tree2d05a7bd808749d1f629b2f0eaad522c33f46280 /src/liblzma/common
parentRevised the Index handling code. (diff)
downloadxz-8ea8dc754a7a5bc2d60db1eac201839cabdab6a1.tar.xz
Fix _memconfig() functions.
This affects lzma_memusage() and lzma_memlimit_get().
Diffstat (limited to 'src/liblzma/common')
-rw-r--r--src/liblzma/common/alone_decoder.c11
-rw-r--r--src/liblzma/common/index_decoder.c10
-rw-r--r--src/liblzma/common/stream_decoder.c11
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;
}