Merge pull request #8496 from s-hadinger/unishox_fix

Fix crash in unishox decompress #8486
This commit is contained in:
Theo Arends 2020-05-20 21:14:25 +02:00 committed by GitHub
commit 3df4161043
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -433,8 +433,8 @@ int32_t Unishox::getNumFromBits(uint32_t count) {
// Code size optimized, recalculate adder[] like in encodeCount
uint32_t Unishox::readCount(void) {
int32_t idx = getCodeIdx(us_hcode);
if ((1 == idx) || (idx >= sizeof(bit_len)) || (idx < 0)) return 0; // unsupported or end of stream
if (idx >= 1) idx--; // we skip v = 1 (code '0') since we no more accept 2 bits encoding
if ((idx >= sizeof(bit_len)) || (idx < 0)) return 0; // unsupported or end of stream
int base;
int till = 0;
@ -470,7 +470,7 @@ int32_t Unishox::unishox_decompress(const char *p_in, size_t p_len, char *p_out,
len <<= 3; // *8, len in bits
out[ol] = 0;
while (bit_no < len) {
while ((byte_no << 3) + bit_no - 8 < len) {
int32_t h, v;
char c = 0;
byte is_upper = is_all_upper;