summaryrefslogtreecommitdiffstats
path: root/decoder.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-02-13 07:03:45 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-02-13 07:04:01 +0000
commit39b772cbf3d797f755f5b1fdb133fea1bedc8178 (patch)
treeaa09ba82ec4995be3d883f18c3a4f80959869f01 /decoder.h
parentReleasing debian version 1.9-5. (diff)
downloadlzlib-39b772cbf3d797f755f5b1fdb133fea1bedc8178.tar.xz
lzlib-39b772cbf3d797f755f5b1fdb133fea1bedc8178.zip
Merging upstream version 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;