Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when scanning invalid regexp
GitHub: #52 As re2 will report the number of capturing groups for an invalid regular expression as -1, we need to check whether a pattern is OK or not before using the number to initialize any vectors, etc. This was causing a crash when using RE2::Scanner#scan with an invalid regular expression as we would attempt to initialize vectors with a length of -1. Instead, set the number of capturing groups to 0 and rely on re2's FindAndConsumeN returning false so we return nil to the user to indicate no match was made.
- Loading branch information