Skip to content

Commit

Permalink
usaddress: fix fuzzer crash
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Jan 24, 2025
1 parent fd235bc commit 62ae35d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/usaddress/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func FuzzStandardizeAddress(f *testing.F) {
" \n \t",
"!@#$%^&*()_+",
"C/O Jane Smith\n123 Unknown Rd\nMystery, ZZ 99999",
"TX 00000",
}

// Add the corpus entries to the fuzzer
Expand Down
2 changes: 1 addition & 1 deletion pkg/usaddress/usaddress.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func StandardizeAddress(addressStr string) Address {
}
}

if stateIndex >= 0 {
if stateIndex > 0 {
// Found state pattern, split accordingly
deliveryLine := strings.Join(words[:stateIndex-1], " ") // Everything before city
lastLine = strings.Join(words[stateIndex-1:], " ") // City and onwards
Expand Down

0 comments on commit 62ae35d

Please sign in to comment.