]> git.eshelyaron.com Git - emacs.git/commitdiff
CC Mode: Prevent infinite recursion in c-determine-limit.
authorAlan Mackenzie <acm@muc.de>
Sun, 5 Feb 2023 18:01:09 +0000 (18:01 +0000)
committerAlan Mackenzie <acm@muc.de>
Sun, 5 Feb 2023 18:01:09 +0000 (18:01 +0000)
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).

lisp/progmodes/cc-engine.el

index 86bc35baa7c091ceed5e742f950758096cd2c930..1899b522ab0395b4f63c043de47a66160b65dd79 100644 (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))))))