1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-23 07:19:15 +00:00

CC Mode: Prevent infinite recursion in c-determine-limit.

This was happening particularly with long-lines, possibly because the position
was inside a literal when calling c-determine-limit.

* lisp/progmodes/cc-engine.el (c-determine-limit): Guard a recursive call by
checking (- base try-size).
This commit is contained in:
Alan Mackenzie 2023-02-05 18:01:09 +00:00
parent 0f4c7060e4
commit 013655811a

View File

@ -5915,19 +5915,21 @@ comment at the start of cc-engine.el for more info."
(cond
((> pos start) ; Nothing but literals
base)
((> base (point-min))
((and
(> base (point-min))
(> (- base try-size) (point-min))) ; prevent infinite recursion.
(c-determine-limit how-far-back base (* 2 try-size) org-start))
(t base)))
((>= count how-far-back)
(c-determine-limit-no-macro
(+ (car elt) (- count how-far-back))
org-start))
(+ (car elt) (- count how-far-back))
org-start))
((eq base (point-min))
(point-min))
((> base (- start try-size)) ; Can only happen if we hit point-min.
(c-determine-limit-no-macro
(car elt)
org-start))
(car elt)
org-start))
(t
(c-determine-limit (- how-far-back count) base (* 2 try-size)
org-start))))))