Avoid regexp stack overflow in GDB string matching (bug#22149)
authorMattias Engdegård <mattiase@acm.org>
Fri, 13 Mar 2020 18:51:02 +0000 (19:51 +0100)
committerMattias Engdegård <mattiase@acm.org>
Sat, 14 Mar 2020 08:32:29 +0000 (09:32 +0100)
* 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.

lisp/progmodes/gdb-mi.el

index da5a2a503a65e7a9c660020bfb83939e47d047f7..c2622327967fc7b13e83f1e521a6bc780d18aa56 100644 (file)
@@ -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)