• Paul Eggert's avatar
    Fix bug where insert-file-contents closes a file twice. · 41d48a42
    Paul Eggert authored
    * fileio.c (close_file_unwind): Don't close if FD is negative;
    this can happen when unwinding a zapped file descriptor.
    (Finsert_file_contents): Unwind-protect the fd before the point marker,
    in case Emacs runs out of memory between the two unwind-protects.
    Don't trash errno when closing FD.
    Zap the FD in the specpdl when closing it, instead of deferring
    the removal of the unwind-protect; this fixes a bug where a child
    function unwinds the stack past us.
    
    Fixes: debbugs:14839
    41d48a42
fileio.c 187 KB