summaryrefslogtreecommitdiffstats
path: root/Utilities/cmliblzma/liblzma/rangecoder
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-08-06 14:24:55 (GMT)
committerBrad King <brad.king@kitware.com>2018-08-06 14:24:55 (GMT)
commit7a976ee74237ad916396ba95a84e6842d79c395c (patch)
tree36b3eddd0d844fbd828959c1f3728e2ceb621286 /Utilities/cmliblzma/liblzma/rangecoder
parent021b54cab8cf52a2ac93e80fbb30a98ed6d5e9f7 (diff)
parent352b8fa70d18ff1664cd8b22f42cf980a976ae4d (diff)
downloadCMake-7a976ee74237ad916396ba95a84e6842d79c395c.zip
CMake-7a976ee74237ad916396ba95a84e6842d79c395c.tar.gz
CMake-7a976ee74237ad916396ba95a84e6842d79c395c.tar.bz2
Merge branch 'upstream-liblzma' into update-liblzma
* upstream-liblzma: liblzma 2018-04-29 (b5be61cc)
Diffstat (limited to 'Utilities/cmliblzma/liblzma/rangecoder')
-rw-r--r--Utilities/cmliblzma/liblzma/rangecoder/range_decoder.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/Utilities/cmliblzma/liblzma/rangecoder/range_decoder.h b/Utilities/cmliblzma/liblzma/rangecoder/range_decoder.h
index fb96180..e0b051f 100644
--- a/Utilities/cmliblzma/liblzma/rangecoder/range_decoder.h
+++ b/Utilities/cmliblzma/liblzma/rangecoder/range_decoder.h
@@ -25,20 +25,26 @@ typedef struct {
/// Reads the first five bytes to initialize the range decoder.
-static inline bool
+static inline lzma_ret
rc_read_init(lzma_range_decoder *rc, const uint8_t *restrict in,
size_t *restrict in_pos, size_t in_size)
{
while (rc->init_bytes_left > 0) {
if (*in_pos == in_size)
- return false;
+ return LZMA_OK;
+
+ // The first byte is always 0x00. It could have been omitted
+ // in LZMA2 but it wasn't, so one byte is wasted in every
+ // LZMA2 chunk.
+ if (rc->init_bytes_left == 5 && in[*in_pos] != 0x00)
+ return LZMA_DATA_ERROR;
rc->code = (rc->code << 8) | in[*in_pos];
++*in_pos;
--rc->init_bytes_left;
}
- return true;
+ return LZMA_STREAM_END;
}