diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-02-13 07:03:45 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2018-02-13 07:04:01 +0000 |
commit | 39b772cbf3d797f755f5b1fdb133fea1bedc8178 (patch) | |
tree | aa09ba82ec4995be3d883f18c3a4f80959869f01 /decoder.h | |
parent | Releasing debian version 1.9-5. (diff) | |
download | lzlib-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.h | 10 |
1 files changed, 4 insertions, 6 deletions
@@ -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; |