* fileio.c (Finsert_file_contents): Avoid double-close.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 25 Jul 2013 07:29:36 +0000 (08:29 +0100)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 25 Jul 2013 07:29:36 +0000 (08:29 +0100)
Fixes: debbugs:14936

src/ChangeLog
src/fileio.c

index 64b13a5..56fe20f 100644 (file)
@@ -1,3 +1,7 @@
+2013-07-25  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * fileio.c (Finsert_file_contents): Avoid double-close (Bug#14936).
+
 2013-07-24  Eli Zaretskii  <eliz@gnu.org>
 
        * xdisp.c (redisplay_window): Instead of moving point out of
index a19fcd9..1350e19 100644 (file)
@@ -3860,7 +3860,11 @@ by calling `format-decode', which see.  */)
       if (same_at_start - BEGV_BYTE == end_offset - beg_offset)
        {
          emacs_close (fd);
-         specpdl_ptr--;
+
+         /* Discard the unwind protect for closing the file, and any
+            unwind protect for restoring point.  */
+         specpdl_ptr = specpdl + fd_index;
+
          /* Truncate the buffer to the size of the file.  */
          del_range_1 (same_at_start, same_at_end, 0, 0);
          goto handled;