Skip to content

ExecBuilder::new() differs from ExecBuilder::new().nfa().build() #268

Closed
@lukaslueg

Description

@lukaslueg

AFL found this example which causes the assertion in main() to fail. This is probably a duplicate of the other reports and there are quite a lot of execution-paths in regex-0.1.73 showing this behavior.

extern crate regex;

use regex::internal::ExecBuilder;

fn main() {
    let res = r"\x20|^d";
    let re0 = ExecBuilder::new(&res).build().unwrap().into_byte_regex();
    let re1 = ExecBuilder::new(&res).nfa().build().unwrap().into_byte_regex();
    let s = " d".as_bytes();
    let m0 = (re0.is_match(s),
              re0.find_iter(s).collect::<Vec<(usize, usize)>>(),
              re0.split(s).collect::<Vec<_>>(),
              re0.captures_iter(s).map(|c| format!("{:?}", c)).collect::<Vec<_>>());
    let m1 = (re1.is_match(s),
              re1.find_iter(s).collect::<Vec<(usize, usize)>>(),
              re1.split(s).collect::<Vec<_>>(),
              re1.captures_iter(s).map(|c| format!("{:?}", c)).collect::<Vec<_>>());
    assert_eq!(m0, m1);
    println!("Done");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions