diff options
| author | Dmitry Antipov | 2013-08-26 09:32:47 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2013-08-26 09:32:47 +0400 |
| commit | de3967312fb2f6c5cb217c3497ad7b4f56e46458 (patch) | |
| tree | fbca05360c8c0769246be71b5100b279b0a9fdd2 /src | |
| parent | 1570ae92dcd05e68509aff5a68d091af9a653c88 (diff) | |
| download | emacs-de3967312fb2f6c5cb217c3497ad7b4f56e46458.tar.gz emacs-de3967312fb2f6c5cb217c3497ad7b4f56e46458.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 10 | ||||
| -rw-r--r-- | src/decompress.c | 7 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f2bb1feb2c2..e4dcfffa02f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,15 @@ | |||
| 1 | 2013-08-26 Dmitry Antipov <dmantipov@yandex.ru> | 1 | 2013-08-26 Dmitry Antipov <dmantipov@yandex.ru> |
| 2 | 2 | ||
| 3 | Fix recovering from possible decompression error. Since | ||
| 4 | insert_from_gap doesn't always move point, we can't use PT as | ||
| 5 | the position where the partially decompressed data ends, and | ||
| 6 | should count how may bytes was produced so far. | ||
| 7 | * decompress.c (struct decompress_unwind_data): Add nbytes member. | ||
| 8 | (unwind_decompress): Really delete partially uncompressed data. | ||
| 9 | (Fzlib_decompress_region): Take decompressed data size into account. | ||
| 10 | |||
| 11 | 2013-08-26 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 12 | |||
| 3 | * syntax.c (init_syntax_once): Adjust comment and do an early | 13 | * syntax.c (init_syntax_once): Adjust comment and do an early |
| 4 | initialization of Qchar_table_extra_slots just once... | 14 | initialization of Qchar_table_extra_slots just once... |
| 5 | * casetab.c (init_casetab_once): | 15 | * casetab.c (init_casetab_once): |
diff --git a/src/decompress.c b/src/decompress.c index c49f39a8ba1..dc9f4b72d93 100644 --- a/src/decompress.c +++ b/src/decompress.c | |||
| @@ -85,7 +85,7 @@ init_zlib_functions (void) | |||
| 85 | 85 | ||
| 86 | struct decompress_unwind_data | 86 | struct decompress_unwind_data |
| 87 | { | 87 | { |
| 88 | ptrdiff_t old_point, start; | 88 | ptrdiff_t old_point, start, nbytes; |
| 89 | z_stream *stream; | 89 | z_stream *stream; |
| 90 | }; | 90 | }; |
| 91 | 91 | ||
| @@ -97,7 +97,7 @@ unwind_decompress (void *ddata) | |||
| 97 | 97 | ||
| 98 | /* Delete any uncompressed data already inserted on error. */ | 98 | /* Delete any uncompressed data already inserted on error. */ |
| 99 | if (data->start) | 99 | if (data->start) |
| 100 | del_range (data->start, PT); | 100 | del_range (data->start, data->start + data->nbytes); |
| 101 | 101 | ||
| 102 | /* Put point where it was, or if the buffer has shrunk because the | 102 | /* Put point where it was, or if the buffer has shrunk because the |
| 103 | compressed data is bigger than the uncompressed, at | 103 | compressed data is bigger than the uncompressed, at |
| @@ -173,7 +173,7 @@ This function can be called only in unibyte buffers. */) | |||
| 173 | unwind_data.start = iend; | 173 | unwind_data.start = iend; |
| 174 | unwind_data.stream = &stream; | 174 | unwind_data.stream = &stream; |
| 175 | unwind_data.old_point = PT; | 175 | unwind_data.old_point = PT; |
| 176 | 176 | unwind_data.nbytes = 0; | |
| 177 | record_unwind_protect_ptr (unwind_decompress, &unwind_data); | 177 | record_unwind_protect_ptr (unwind_decompress, &unwind_data); |
| 178 | 178 | ||
| 179 | /* Insert the decompressed data at the end of the compressed data. */ | 179 | /* Insert the decompressed data at the end of the compressed data. */ |
| @@ -201,6 +201,7 @@ This function can be called only in unibyte buffers. */) | |||
| 201 | pos_byte += avail_in - stream.avail_in; | 201 | pos_byte += avail_in - stream.avail_in; |
| 202 | decompressed = avail_out - stream.avail_out; | 202 | decompressed = avail_out - stream.avail_out; |
| 203 | insert_from_gap (decompressed, decompressed, 0); | 203 | insert_from_gap (decompressed, decompressed, 0); |
| 204 | unwind_data.nbytes += decompressed; | ||
| 204 | QUIT; | 205 | QUIT; |
| 205 | } | 206 | } |
| 206 | while (inflate_status == Z_OK); | 207 | while (inflate_status == Z_OK); |