summaryrefslogtreecommitdiffstats
path: root/decoder.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 07:23:00 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 07:23:00 +0000
commit7cad15d85d55c7ad11cb25c2ec5e8cd17ecc84ee (patch)
treec998e3ce491834f84eb9b733c757d83efed25842 /decoder.cc
parentAdding upstream version 1.6~pre1. (diff)
downloadlzip-7cad15d85d55c7ad11cb25c2ec5e8cd17ecc84ee.tar.xz
lzip-7cad15d85d55c7ad11cb25c2ec5e8cd17ecc84ee.zip
Adding upstream version 1.6~pre2.upstream/1.6_pre2
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decoder.cc')
-rw-r--r--decoder.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/decoder.cc b/decoder.cc
index 341740b..aeac2cd 100644
--- a/decoder.cc
+++ b/decoder.cc
@@ -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 );
}
}