Subject: bug#40317: 27.0.90; Reverting a buffer that visits C file signals an error

From: Damien Cassou <[email-masked]>
Date: Fri, 18 Sep 2020 21:46:03 +0200

Hi Jeff,

Jeff Norden <[email-masked]> writes:
> Unfortunately, I can't figure out how to trigger this bug myself.  If you want
> to be 100% sure about it, you might try adding
>
>   (if (> c-new-END (point-max))
>     (error "c-new-END is too big! %d > %d" c-new-END (point-max)))
>
> right after line-2009 and see if it raises an error before it gets to
> parse-partial-sexp.

I wasn't sure if you wanted me to only add the `if` or if you wanted me
to also change the previous line. I've just added the `if` with the
attached patch and will report if I get the new error message.

-- 
Damien Cassou

"Success is the ability to go from one failure to another without
losing enthusiasm." --Winston Churchill
--- a/lisp/progmodes/cc-mode.el.orig	2020-07-29 23:40:41.000000000 +0200
+++ b/lisp/progmodes/cc-mode.el	2020-09-18 15:36:37.409779350 +0200
@@ -2007,6 +2007,10 @@
   ;; larger than (beg end).
   (setq c-new-END (- (+ c-new-END (- end beg)) old-len))
 
+  ;; Trying to fix bug#40317
+  (if (> c-new-END (point-max))
+         (error "c-new-END is too big! %d > %d" c-new-END (point-max)))
+
   (unless (c-called-from-text-property-change-p)
     (setq c-just-done-before-change nil)
     (c-save-buffer-state (case-fold-search)