Skip to content

Commit

Permalink
go: check for out of range indices in asm check helper (pantsbuild#18095
Browse files Browse the repository at this point in the history
)

I was seeing some segfaults with the assembly checker helper. Add an index check to ensure we don't access out of bounds indices.
  • Loading branch information
tdyas authored Jan 27, 2023
1 parent 0e6d38f commit 3ec502b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/python/pants/backend/go/go_sources/asm_check/asm_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ func maybeGolangAssembly(filename string) (bool, error) {
}

func main() {
for _, arg := range os.Args {
found, err := maybeGolangAssembly(arg)
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
os.Exit(1)
}
if len(os.Args) >= 2 {
for _, arg := range os.Args[1:] {
found, err := maybeGolangAssembly(arg)
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
os.Exit(1)
}

if found {
fmt.Printf("%s\n", arg)
if found {
fmt.Printf("%s\n", arg)
}
}
}
}

0 comments on commit 3ec502b

Please sign in to comment.