google / re2j

linear time regular expression matching in Java
Other
1.19k stars 160 forks source link

Pattern Leading to NullPointerException #148

Closed schirrmacher closed 1 year ago

schirrmacher commented 3 years ago

When I compile the pattern: "..|.#|..":

Pattern.compile("..|.#|..")

I get java.lang.NullPointerException exception.

== Java Exception: java.lang.NullPointerException: Cannot read the array length because "subMax.runes" is null
    at com.google.re2j.Parser.factor(Parser.java:552)
    at com.google.re2j.Parser.collapse(Parser.java:344)
    at com.google.re2j.Parser.factor(Parser.java:512)
    at com.google.re2j.Parser.collapse(Parser.java:344)
    at com.google.re2j.Parser.alternate(Parser.java:294)
    at com.google.re2j.Parser.parseInternal(Parser.java:975)
    at com.google.re2j.Parser.parse(Parser.java:788)
    at com.google.re2j.RE2.compileImpl(RE2.java:187)
    at com.google.re2j.Pattern.compile(Pattern.java:149)
    at com.google.re2j.Pattern.compile(Pattern.java:107)

I applied the Jazzer Fuzzer to your lib. Maybe an integration is worth it.

sjamesr commented 1 year ago

This was fixed in #149