1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-30 04:10:54 -08:00

Fix clobbering of match data in executable-set-magic

* lisp/progmodes/executable.el (executable-set-magic): Switching
buffers may clobber match data, so save the match data first
(bug#54218).
This commit is contained in:
Lars Ingebrigtsen 2022-03-03 15:43:35 +01:00
parent d72cd4a2b7
commit b6587090bf

View file

@ -240,12 +240,13 @@ executable."
(not (string= argument
(buffer-substring (point) (match-end 1))))
(if (or (not executable-query) no-query-flag
(save-window-excursion
;; Make buffer visible before question.
(switch-to-buffer (current-buffer))
(y-or-n-p (format-message
"Replace magic number by `#!%s'? "
argument))))
(save-match-data
(save-window-excursion
;; Make buffer visible before question.
(switch-to-buffer (current-buffer))
(y-or-n-p (format-message
"Replace magic number by `#!%s'? "
argument)))))
(progn
(replace-match argument t t nil 1)
(message "Magic number changed to `#!%s'" argument))))