Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
regcomp.c: Avoid a panic on malformed qr/\N{..}/i
Input constructs that expand to more than one character are handled very very specially when they occur within a bracketed character class. What happens effectively is that they are removed from the class and parsed separately, using the regular code in regcomp.c to generate something like a trie for them. The other characters within the class are handled normally. The specially handled stuff is parsed from a separate string. In the case where that stuff is of the form \N{U+...}, I neglected to adequately consider that the syntax could trigger an error. When such an error is raised, it can violate our assumptions about the state of things, and lead to a panic. THe code actually parses the construct twice. The first time while deciding if this expands to multiple characters (so that it can be separated out), and the second time to actually figure out and return the expansion. This commit fixes the bug by adding error checking during the first pass. Previously, the minimal amount of work was done to be able to find the count of characters in the expansion. Now, more work is done to do the checking, as we go along with the counting. This actually results in less special case code needing to be executed, so there is a net code removal from this commit.
- Loading branch information