diff options
Diffstat (limited to '')
-rw-r--r-- | decoder.cc | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -47,6 +47,7 @@ void LZ_decoder::flush_data() { if( !member_finished ) { + crc32.update( crc_, buffer, pos ); if( odes_ >= 0 ) { const int wr = writeblock( odes_, (char *)buffer, pos ); @@ -65,7 +66,9 @@ bool LZ_decoder::verify_trailer( const Pretty_print & pp ) const const int trailer_size = trailer.size( format_version ); for( int i = 0; i < trailer_size && !error; ++i ) { - if( range_decoder.finished() ) + if( !range_decoder.finished() ) + ((uint8_t *)&trailer)[i] = range_decoder.get_byte(); + else { error = true; if( verbosity >= 0 ) @@ -75,7 +78,6 @@ bool LZ_decoder::verify_trailer( const Pretty_print & pp ) const " some checks may fail.\n", i ); } } - ((uint8_t *)&trailer)[i] = range_decoder.read_byte(); } if( format_version == 0 ) trailer.member_size( member_position() ); if( trailer.data_crc() != crc() ) @@ -195,23 +197,22 @@ int LZ_decoder::decode_member( const Pretty_print & pp ) rep0 += range_decoder.decode_tree_reversed( bm_align, dis_align_bits ); if( rep0 == 0xFFFFFFFF ) // Marker found { + range_decoder.normalize(); + flush_data(); if( len == min_match_len ) // End Of Stream marker - { - flush_data(); - if( verify_trailer( pp ) ) return 0; else return 3; - } + { if( verify_trailer( pp ) ) return 0; else return 3; } if( verbosity >= 0 ) { pp(); std::fprintf( stderr, "unsupported marker code `%d'.\n", len ); } - flush_data(); return 4; } + if( rep0 >= (unsigned int)buffer_size ) { flush_data(); return 1; } } } } - if( !copy_block( rep0, len ) ) { flush_data(); return 1; } + copy_block( rep0, len ); prev_byte = get_byte( 0 ); } } |