summaryrefslogtreecommitdiffstats
path: root/decoder.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-02-13 07:03:42 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-02-13 07:03:42 +0000
commit07a9feadab39c03c44ce074320b90f75e232c511 (patch)
treefe7fb3cc84a73bc6cbda192ced4414ff80c3322f /decoder.h
parentAdding upstream version 1.9. (diff)
downloadlzlib-07a9feadab39c03c44ce074320b90f75e232c511.tar.xz
lzlib-07a9feadab39c03c44ce074320b90f75e232c511.zip
Adding upstream version 1.10.upstream/1.10
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'decoder.h')
-rw-r--r--decoder.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/decoder.h b/decoder.h
index 8e422a8..090bf3a 100644
--- a/decoder.h
+++ b/decoder.h
@@ -1,5 +1,5 @@
/* Lzlib - Compression library for the lzip format
- Copyright (C) 2009-2017 Antonio Diaz Diaz.
+ Copyright (C) 2009-2018 Antonio Diaz Diaz.
This library is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided
@@ -319,11 +319,7 @@ static inline bool LZd_enough_free_bytes( const struct LZ_decoder * const d )
{ return Cb_free_bytes( &d->cb ) >= lzd_min_free_bytes; }
static inline uint8_t LZd_peek_prev( const struct LZ_decoder * const d )
- {
- if( d->cb.put > 0 ) return d->cb.buffer[d->cb.put-1];
- if( d->pos_wrapped ) return d->cb.buffer[d->cb.buffer_size-1];
- return 0; /* prev_byte of first byte */
- }
+ { return d->cb.buffer[((d->cb.put > 0) ? d->cb.put : d->cb.buffer_size)-1]; }
static inline uint8_t LZd_peek( const struct LZ_decoder * const d,
const unsigned distance )
@@ -387,6 +383,8 @@ static inline bool LZd_init( struct LZ_decoder * const d,
d->member_finished = false;
d->verify_trailer_pending = false;
d->pos_wrapped = false;
+ /* prev_byte of first byte; also for LZd_peek( 0 ) on corrupt file */
+ d->cb.buffer[d->cb.buffer_size-1] = 0;
d->rep0 = 0;
d->rep1 = 0;
d->rep2 = 0;