Skip to content

Commit

Permalink
Fixed starting at string's length.
Browse files Browse the repository at this point in the history
  • Loading branch information
dop251 committed Aug 6, 2020
1 parent 5b52bb1 commit 104f7f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions regexp.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ func (re *Regexp) getRunesAndStart(s string, startAt int) ([]rune, int) {
ret[i] = r
i++
}
if startAt == len(s) {
runeIdx = i
}
return ret[:i], runeIdx
}

Expand Down
11 changes: 11 additions & 0 deletions regexp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,17 @@ func TestAlternationConstruct_Matches(t *testing.T) {
}
}

func TestStartAtEnd(t *testing.T) {
re := MustCompile("(?:)", 0)
m, err := re.FindStringMatchStartingAt("t", 1)
if err != nil {
t.Fatal(err)
}
if m == nil {
t.Fatal("Expected match")
}
}

func TestParserFuzzCrashes(t *testing.T) {
var crashes = []string{
"(?'-", "(\\c0)", "(\\00(?())", "[\\p{0}", "(\x00?.*.()?(()?)?)*.x\xcb?&(\\s\x80)", "\\p{0}", "[0-[\\p{0}",
Expand Down

0 comments on commit 104f7f5

Please sign in to comment.