Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option::unwrap() called on None-value in Regex::new() #257

Closed
lukaslueg opened this issue Jun 21, 2016 · 2 comments
Closed

Option::unwrap() called on None-value in Regex::new() #257

lukaslueg opened this issue Jun 21, 2016 · 2 comments
Labels

Comments

@lukaslueg
Copy link
Contributor

AFL found this regex which causes Regex::new() in regex-0.1.71 to call Option::unwrap() on a None-value, causing a panic

r"[^\D\d]"
@BurntSushi
Copy link
Member

@lukaslueg Thank you for filing all these bugs. I can't wait to fix them. :-)

@BurntSushi BurntSushi added the bug label Jul 9, 2016
@BurntSushi
Copy link
Member

This particular bug is a result of two things:

  1. [^\D\d] is actually an empty character class, since [\D\d] says "match anything" and [^\D\d] says "match !anything."
  2. The compiler assumes that empty character classes are impossible.

I'd like to fix this by more explicitly banning empty character classes. Other regex engines actually allow them and treat them as "never match anything." It seems more sensible (and more conservative) to just ban them outright.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants