Restore current buffer after clone-indirect-buffer-hook errors

* src/buffer.c (Fmake_indirect_buffer): Replace
set_buffer_internal_1 with specpdl unwind in the clone path
(bug#81504).

Copyright-paperwork-exempt: yes
This commit is contained in:
Donjuanplatinum 2026-07-28 01:25:56 +08:00 committed by Sean Whitton
parent b21266e4cb
commit c6e2bd3e3b

View file

@ -937,7 +937,7 @@ Interactively, CLONE and INHIBIT-BUFFER-HOOKS are nil. */)
}
else
{
struct buffer *old_b = current_buffer;
specpdl_ref count = SPECPDL_INDEX ();
clone_per_buffer_values (b->base_buffer, b);
bset_filename (b, Qnil);
@ -946,6 +946,7 @@ Interactively, CLONE and INHIBIT-BUFFER-HOOKS are nil. */)
bset_backed_up (b, Qnil);
bset_local_minor_modes (b, Qnil);
bset_auto_save_file_name (b, Qnil);
record_unwind_current_buffer ();
set_buffer_internal_1 (b);
Fset (Qbuffer_save_without_query, Qnil);
Fset (Qbuffer_file_number, Qnil);
@ -955,7 +956,7 @@ Interactively, CLONE and INHIBIT-BUFFER-HOOKS are nil. */)
variable copies for list variables that might be mangled due
to destructive operations in the indirect buffer. */
run_hook (Qclone_indirect_buffer_hook);
set_buffer_internal_1 (old_b);
unbind_to (count, Qnil);
}
run_buffer_list_update_hook (b);