summaryrefslogtreecommitdiffstats
path: root/decoder.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:16:13 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 10:16:13 +0000
commitf8ec1a9b6de5ccde4220017676cbae1c16205fd1 (patch)
treec76650bdeec7078ff209e394b3d091bbbabb40f9 /decoder.cc
parentAdding debian version 1.13~rc1-1. (diff)
downloadlziprecover-f8ec1a9b6de5ccde4220017676cbae1c16205fd1.tar.xz
lziprecover-f8ec1a9b6de5ccde4220017676cbae1c16205fd1.zip
Merging upstream version 1.13~rc2.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--decoder.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/decoder.cc b/decoder.cc
index b9fc3d8..e15b2ec 100644
--- a/decoder.cc
+++ b/decoder.cc
@@ -108,9 +108,14 @@ void LZ_decoder::flush_data()
if( size > 0 )
{
crc32.update( crc_, buffer + stream_pos, size );
- if( outfd >= 0 &&
- writeblock( outfd, buffer + stream_pos, size ) != size )
- throw Error( "Write error" );
+ if( outfd >= 0 )
+ {
+ const long long i = std::max( 0LL, outskip - stream_position() );
+ const long long s =
+ std::min( outend - stream_position(), (long long)size ) - i;
+ if( s > 0 && writeblock( outfd, buffer + stream_pos + i, s ) != s )
+ throw Error( "Write error" );
+ }
if( pos >= buffer_size ) { partial_data_pos += pos; pos = 0; }
stream_pos = pos;
}