From: Mattias EngdegÄrd Date: Thu, 7 Feb 2019 18:05:06 +0000 (+0100) Subject: Check validity of rx submatch-n number X-Git-Tag: emacs-27.0.90~2295 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2eafb4af55cc835694a0e747835b88145d20a94d;p=emacs.git Check validity of rx submatch-n number * lisp/emacs-lisp/rx.el (rx-submatch): Type and range check (Bug#34373). --- diff --git a/lisp/emacs-lisp/rx.el b/lisp/emacs-lisp/rx.el index 8ef78fd69e6..2130e3e1aea 100644 --- a/lisp/emacs-lisp/rx.el +++ b/lisp/emacs-lisp/rx.el @@ -725,6 +725,8 @@ FORM is either `(repeat N FORM1)' or `(repeat N M FORMS...)'." (defun rx-submatch-n (form) "Parse and produce code from FORM, which is `(submatch-n N ...)'." (let ((n (nth 1 form))) + (unless (and (integerp n) (> n 0)) + (error "rx `submatch-n' argument must be positive")) (concat "\\(?" (number-to-string n) ":" (if (= 3 (length form)) ;; Only one sub-form.