emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r114001: Fix recovering from possible decompression


From: Dmitry Antipov
Subject: [Emacs-diffs] trunk r114001: Fix recovering from possible decompression error. Since
Date: Mon, 26 Aug 2013 05:33:19 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 114001
revision-id: address@hidden
parent: address@hidden
committer: Dmitry Antipov <address@hidden>
branch nick: trunk
timestamp: Mon 2013-08-26 09:32:47 +0400
message:
  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.
modified:
  src/ChangeLog                  changelog-20091113204419-o5vbwnq5f7feedwu-1438
  src/decompress.c               decompress.c-20130811194033-wfhl0tqmmc36jfmu-1
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2013-08-26 05:20:59 +0000
+++ b/src/ChangeLog     2013-08-26 05:32:47 +0000
@@ -1,5 +1,15 @@
 2013-08-26  Dmitry Antipov  <address@hidden>
 
+       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  <address@hidden>
+
        * syntax.c (init_syntax_once): Adjust comment and do an early
        initialization of Qchar_table_extra_slots just once...
        * casetab.c (init_casetab_once):

=== modified file 'src/decompress.c'
--- a/src/decompress.c  2013-08-17 17:18:07 +0000
+++ b/src/decompress.c  2013-08-26 05:32:47 +0000
@@ -85,7 +85,7 @@
 
 struct decompress_unwind_data
 {
-  ptrdiff_t old_point, start;
+  ptrdiff_t old_point, start, nbytes;
   z_stream *stream;
 };
 
@@ -97,7 +97,7 @@
 
   /* 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
@@ -173,7 +173,7 @@
   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.  */
@@ -201,6 +201,7 @@
       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);


reply via email to

[Prev in Thread] Current Thread [Next in Thread]