From: Paul Eggert Date: Sat, 19 Aug 2017 06:52:19 +0000 (-0700) Subject: Fix recently-introduced file descriptor leak X-Git-Tag: emacs-26.0.90~413 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6763399ef3f268269fefd75d7c7a4ac012f66833;p=emacs.git Fix recently-introduced file descriptor leak * src/fileio.c (Fmake_temp_file_internal): Don’t leak a file descriptor if write_region signals an error. --- diff --git a/src/fileio.c b/src/fileio.c index 6b3bdf2154d..f954ac12b5d 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -693,10 +693,14 @@ This function does not grok magic file names. */) bool failed = fd < 0; if (!failed) { + ptrdiff_t count = SPECPDL_INDEX (); + record_unwind_protect_int (close_file_unwind, fd); val = DECODE_FILE (val); if (STRINGP (text) && SBYTES (text) != 0) write_region (text, Qnil, val, Qnil, Qnil, Qnil, Qnil, fd); failed = NILP (dir_flag) && emacs_close (fd) != 0; + /* Discard the unwind protect. */ + specpdl_ptr = specpdl + count; } if (failed) {