+2013-08-26 Dmitry Antipov <dmantipov@yandex.ru>
+
+ Fix recovering from possible decompression error. Since
+ insert_from_gap doesn't always move point, we can't use PT as
+ the position where the partially decompressed data ends, and
+ should count how may bytes was produced so far.
+ * decompress.c (struct decompress_unwind_data): Add nbytes member.
+ (unwind_decompress): Really delete partially uncompressed data.
+ (Fzlib_decompress_region): Take decompressed data size into account.
+
2013-08-26 Dmitry Antipov <dmantipov@yandex.ru>
* syntax.c (init_syntax_once): Adjust comment and do an early
\f
struct decompress_unwind_data
{
- ptrdiff_t old_point, start;
+ ptrdiff_t old_point, start, nbytes;
z_stream *stream;
};
/* Delete any uncompressed data already inserted on error. */
if (data->start)
- del_range (data->start, PT);
+ del_range (data->start, data->start + data->nbytes);
/* Put point where it was, or if the buffer has shrunk because the
compressed data is bigger than the uncompressed, at
unwind_data.start = iend;
unwind_data.stream = &stream;
unwind_data.old_point = PT;
-
+ unwind_data.nbytes = 0;
record_unwind_protect_ptr (unwind_decompress, &unwind_data);
/* Insert the decompressed data at the end of the compressed data. */
pos_byte += avail_in - stream.avail_in;
decompressed = avail_out - stream.avail_out;
insert_from_gap (decompressed, decompressed, 0);
+ unwind_data.nbytes += decompressed;
QUIT;
}
while (inflate_status == Z_OK);