[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] emacs-25 fe27e03: Fix rx matcher overflow without limi
From: |
Stefan Monnier |
Subject: |
Re: [Emacs-diffs] emacs-25 fe27e03: Fix rx matcher overflow without limiting |
Date: |
Mon, 14 Dec 2015 12:34:59 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
> -
> "\\[[^][]\\{0,2000\\}\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?")
> + ;;
> + ;; If you think the first shy group is a bit strange, it is like
> + ;; that in order not to overflow the regexp matcher stack in the
> + ;; presence of unbalanced brackets, i.e., a [ and then no
> + ;; closing bracket anymore. In "[^[],]*,", the "*" repetition
> + ;; will be done without any need to record state for eventual
> + ;; backtracking because the "," is mutually exclusive with the
> + ;; "[^][,]", and the regexp matcher includes a special
> + ;; optimization for that case since it's common and very
> + ;; useful). (Hint by Stefan Monnier)
> + "\\[\\(?:[^][,]*,\\)*[
> \t]*\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?")
As mentioned in my email, this doesn't remove all risks of overflows,
since the second * still requires stashing the state onto the stack for
backtracking, but that's only "once per comma" instead of "once
per char", so in practice we can hope we won't bump into it.
Stefan
- Re: [Emacs-diffs] emacs-25 fe27e03: Fix rx matcher overflow without limiting,
Stefan Monnier <=