From: Alan Mackenzie Date: Sun, 5 Feb 2023 18:01:09 +0000 (+0000) Subject: CC Mode: Prevent infinite recursion in c-determine-limit. X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=013655811aa1c89754372610c8c6ccccec166035;p=emacs.git 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). --- diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 86bc35baa7c..1899b522ab0 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -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))))))