1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-14 19:01:45 -07:00

CC Mode: Fix infinite loop in c-brace-stack-at.

This fixes bug #59038.  The infinite loop occurred with a buffer containing
Base-64 encoded text rather than appropriate C Mode text.

* lisp/progmodes/cc-engine.el (c-update-brace-stack): Don't execute
c-beginning-of-current-token unless the previous c-syntactic-re-search-forward
has succeeded at least once.
This commit is contained in:
Alan Mackenzie 2022-11-07 12:20:07 +00:00
parent 802671493d
commit c19ca5eb7f

View file

@ -6158,9 +6158,10 @@ comment at the start of cc-engine.el for more info."
(setq s (cdr s))))
((c-keyword-member kwd-sym 'c-flat-decl-block-kwds)
(push 0 s))))
;; The failing `c-syntactic-re-search-forward' may have left us in the
;; middle of a token, which might be a significant token. Fix this!
(c-beginning-of-current-token)
(when (> prev-match-pos 1) ; Has the search matched at least once?
;; The failing `c-syntactic-re-search-forward' may have left us in the
;; middle of a token, which might be a significant token. Fix this!
(c-beginning-of-current-token))
(cons (point)
(cons bound-<> s)))))