From 9d611ffe280d0af4aa43406e5e102636606d3204 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 25 Jul 2013 08:29:36 +0100 Subject: [PATCH] * fileio.c (Finsert_file_contents): Avoid double-close. Fixes: debbugs:14936 --- src/ChangeLog | 4 ++++ src/fileio.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 64b13a5ac28..56fe20fda98 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2013-07-25 Paul Eggert + + * fileio.c (Finsert_file_contents): Avoid double-close (Bug#14936). + 2013-07-24 Eli Zaretskii * xdisp.c (redisplay_window): Instead of moving point out of diff --git a/src/fileio.c b/src/fileio.c index a19fcd9f663..1350e19ef27 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -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; -- 2.11.4.GIT