From: Mattias EngdegÄrd Date: Fri, 13 Mar 2020 18:51:02 +0000 (+0100) Subject: Avoid regexp stack overflow in GDB string matching (bug#22149) X-Git-Tag: emacs-28.0.90~7761 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7195ea7532f4b2e05f168da823d9aed2401267cf;p=emacs.git Avoid regexp stack overflow in GDB string matching (bug#22149) * lisp/progmodes/gdb-mi.el (gdb--string-regexp): Swap the or-clauses so that the rarely matching one comes first. This avoids a build-up of backtrack points on the regexp stack. --- diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index da5a2a503a6..c2622327967 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -1046,7 +1046,10 @@ no input, and GDB is waiting for input." (declare-function tooltip-show "tooltip" (text &optional use-echo-area)) -(defconst gdb--string-regexp "\"\\(?:[^\\\"]\\|\\\\.\\)*\"") +(defconst gdb--string-regexp (rx "\"" + (* (or (seq "\\" nonl) + (not (any "\"\\")))) + "\"")) (defun gdb-tooltip-print (expr) (with-current-buffer (gdb-get-buffer 'gdb-partial-output-buffer)