summaryrefslogtreecommitdiffstats
path: root/decoder.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-10-22 16:37:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-10-22 16:37:26 +0000
commit840485ecc9ca5fdf8e3b922327ca07b18b13823e (patch)
tree3f1a5c1975da55170854a85453cb467331a33cd1 /decoder.h
parentReleasing debian version 1.15~pre1-1. (diff)
downloadlzlib-840485ecc9ca5fdf8e3b922327ca07b18b13823e.tar.xz
lzlib-840485ecc9ca5fdf8e3b922327ca07b18b13823e.zip
Merging upstream version 1.15~pre2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--decoder.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/decoder.h b/decoder.h
index 4b91fec..57e47cb 100644
--- a/decoder.h
+++ b/decoder.h
@@ -133,13 +133,15 @@ static inline bool Rd_unread_data( struct Range_decoder * const rdec,
return true;
}
-static bool Rd_try_reload( struct Range_decoder * const rdec )
+static int Rd_try_reload( struct Range_decoder * const rdec )
{
if( rdec->reload_pending && Rd_available_bytes( rdec ) >= 5 )
{
rdec->reload_pending = false;
rdec->code = 0;
rdec->range = 0xFFFFFFFFU;
+ /* check first byte of the LZMA stream without reading it */
+ if( rdec->cb.buffer[rdec->cb.get] != 0 ) return 2;
Rd_get_byte( rdec ); /* discard first byte of the LZMA stream */
int i; for( i = 0; i < 4; ++i )
rdec->code = (rdec->code << 8) | Rd_get_byte( rdec );
@@ -164,7 +166,7 @@ static inline unsigned Rd_decode( struct Range_decoder * const rdec,
rdec->range >>= 1;
/* symbol <<= 1; */
/* if( rdec->code >= rdec->range ) { rdec->code -= rdec->range; symbol |= 1; } */
- const bool bit = ( rdec->code >= rdec->range );
+ const bool bit = rdec->code >= rdec->range;
symbol <<= 1; symbol += bit;
rdec->code -= rdec->range & ( 0U - bit );
}
@@ -387,14 +389,14 @@ static inline void LZd_copy_block( struct LZ_decoder * const d,
bool fast, fast2;
if( lpos > distance )
{
- fast = ( len < d->cb.buffer_size - lpos );
- fast2 = ( fast && len <= lpos - i );
+ fast = len < d->cb.buffer_size - lpos;
+ fast2 = fast && len <= lpos - i;
}
else
{
i += d->cb.buffer_size;
- fast = ( len < d->cb.buffer_size - i ); /* (i == pos) may happen */
- fast2 = ( fast && len <= i - lpos );
+ fast = len < d->cb.buffer_size - i; /* (i == pos) may happen */
+ fast2 = fast && len <= i - lpos;
}
if( fast ) /* no wrap */
{