diff options
Diffstat (limited to 'decoder.c')
-rw-r--r-- | decoder.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -35,7 +35,7 @@ static int LZd_try_check_trailer( struct LZ_decoder * const d ) /* Return value: 0 = OK, 1 = decoder error, 2 = unexpected EOF, 3 = trailer error, 4 = unknown marker found, - 5 = library error. */ + 5 = nonzero first LZMA byte found, 6 = library error. */ static int LZd_decode_member( struct LZ_decoder * const d ) { struct Range_decoder * const rdec = d->rdec; @@ -43,14 +43,15 @@ static int LZd_decode_member( struct LZ_decoder * const d ) unsigned old_mpos = rdec->member_position; if( d->member_finished ) return 0; - if( !Rd_try_reload( rdec ) ) - { if( !rdec->at_stream_end ) return 0; else return 2; } + const int tmp = Rd_try_reload( rdec ); + if( tmp > 1 ) return 5; + if( !tmp ) { if( !rdec->at_stream_end ) return 0; else return 2; } if( d->check_trailer_pending ) return LZd_try_check_trailer( d ); while( !Rd_finished( rdec ) ) { const unsigned mpos = rdec->member_position; - if( mpos - old_mpos > rd_min_available_bytes ) return 5; + if( mpos - old_mpos > rd_min_available_bytes ) return 6; old_mpos = mpos; if( !Rd_enough_available_bytes( rdec ) ) /* check unexpected EOF */ { if( !rdec->at_stream_end ) return 0; @@ -117,7 +118,7 @@ static int LZd_decode_member( struct LZ_decoder * const d ) { Rd_normalize( rdec ); const unsigned mpos = rdec->member_position; - if( mpos - old_mpos > rd_min_available_bytes ) return 5; + if( mpos - old_mpos > rd_min_available_bytes ) return 6; old_mpos = mpos; if( len == min_match_len ) /* End Of Stream marker */ { @@ -127,7 +128,9 @@ static int LZd_decode_member( struct LZ_decoder * const d ) if( len == min_match_len + 1 ) /* Sync Flush marker */ { rdec->reload_pending = true; - if( Rd_try_reload( rdec ) ) continue; + const int tmp = Rd_try_reload( rdec ); + if( tmp > 1 ) return 5; + if( tmp ) continue; if( !rdec->at_stream_end ) return 0; else break; } return 4; |