aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2017-08-18 23:52:19 -0700
committerPaul Eggert2017-08-18 23:52:52 -0700
commit6763399ef3f268269fefd75d7c7a4ac012f66833 (patch)
treef034b3070353b5bba3962f3f3132cc79ecd78da7 /src
parente73691e1a47834aff367c9131fc3c7d78751d821 (diff)
downloademacs-6763399ef3f268269fefd75d7c7a4ac012f66833.tar.gz
emacs-6763399ef3f268269fefd75d7c7a4ac012f66833.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c4
1 files changed, 4 insertions, 0 deletions
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. */)
693 bool failed = fd < 0; 693 bool failed = fd < 0;
694 if (!failed) 694 if (!failed)
695 { 695 {
696 ptrdiff_t count = SPECPDL_INDEX ();
697 record_unwind_protect_int (close_file_unwind, fd);
696 val = DECODE_FILE (val); 698 val = DECODE_FILE (val);
697 if (STRINGP (text) && SBYTES (text) != 0) 699 if (STRINGP (text) && SBYTES (text) != 0)
698 write_region (text, Qnil, val, Qnil, Qnil, Qnil, Qnil, fd); 700 write_region (text, Qnil, val, Qnil, Qnil, Qnil, Qnil, fd);
699 failed = NILP (dir_flag) && emacs_close (fd) != 0; 701 failed = NILP (dir_flag) && emacs_close (fd) != 0;
702 /* Discard the unwind protect. */
703 specpdl_ptr = specpdl + count;
700 } 704 }
701 if (failed) 705 if (failed)
702 { 706 {