summaryrefslogtreecommitdiffstats
path: root/decoder.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-02-13 06:55:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-02-13 06:55:43 +0000
commita382a7a69612ffd005ce4ee79016d1d4eb6173e9 (patch)
treeb15eb5678296f0b5d20f2a75aa626a850aac421f /decoder.h
parentAdding upstream version 1.9. (diff)
downloadclzip-a382a7a69612ffd005ce4ee79016d1d4eb6173e9.tar.xz
clzip-a382a7a69612ffd005ce4ee79016d1d4eb6173e9.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 2f96575..11ba869 100644
--- a/decoder.h
+++ b/decoder.h
@@ -1,5 +1,5 @@
/* Clzip - LZMA lossless data compressor
- Copyright (C) 2010-2017 Antonio Diaz Diaz.
+ Copyright (C) 2010-2018 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -239,11 +239,7 @@ struct LZ_decoder
void LZd_flush_data( struct LZ_decoder * const d );
static inline uint8_t LZd_peek_prev( const struct LZ_decoder * const d )
- {
- if( d->pos > 0 ) return d->buffer[d->pos-1];
- if( d->pos_wrapped ) return d->buffer[d->dictionary_size-1];
- return 0; /* prev_byte of first byte */
- }
+ { return d->buffer[((d->pos > 0) ? d->pos : d->dictionary_size)-1]; }
static inline uint8_t LZd_peek( const struct LZ_decoder * const d,
const unsigned distance )
@@ -305,6 +301,8 @@ static inline bool LZd_init( struct LZ_decoder * const d,
d->crc = 0xFFFFFFFFU;
d->outfd = ofd;
d->pos_wrapped = false;
+ /* prev_byte of first byte; also for LZd_peek( 0 ) on corrupt file */
+ d->buffer[d->dictionary_size-1] = 0;
return true;
}