summaryrefslogtreecommitdiffstats
path: root/decoder.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2018-02-13 06:58:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2018-02-13 06:59:21 +0000
commit7dd21df678aafaba8614ffe90188712f13b3bfc3 (patch)
treebbfc9eedb166e5e3e154b4ad28f4212bdb239d03 /decoder.h
parentReleasing debian version 1.9-4. (diff)
downloadlunzip-7dd21df678aafaba8614ffe90188712f13b3bfc3.tar.xz
lunzip-7dd21df678aafaba8614ffe90188712f13b3bfc3.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 e3a4f1c..7ec3133 100644
--- a/decoder.h
+++ b/decoder.h
@@ -1,5 +1,5 @@
/* Lunzip - Decompressor for the lzip format
- 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
@@ -244,11 +244,7 @@ unsigned seek_read_back( const int fd, uint8_t * const buf, const int size,
const int offset );
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->buffer_size-1];
- return 0; /* prev_byte of first byte */
- }
+ { return d->buffer[((d->pos > 0) ? d->pos : d->buffer_size)-1]; }
static inline uint8_t LZd_peek( const struct LZ_decoder * const d,
const unsigned distance )
@@ -338,6 +334,8 @@ static inline bool LZd_init( struct LZ_decoder * const d,
d->outfd = ofd;
d->pos_wrapped = false;
d->pos_wrapped_dic = false;
+ /* prev_byte of first byte; also for LZd_peek( 0 ) on corrupt file */
+ d->buffer[d->buffer_size-1] = 0;
return true;
}