* src/fileio.c (Fmake_temp_file_internal):
Don’t leak a file descriptor if write_region signals an error.
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)
{