mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
main: fix USB vid/pid lookup
I introduced a bug in #3207: looking up a VID/PID pair would result in a slice out of bounds panic. This is a trivial fix for that bug.
This commit is contained in:
committed by
Ron Evans
parent
9de757205f
commit
2b04006b1e
@@ -1028,11 +1028,11 @@ func getDefaultPort(portFlag string, usbInterfaces []string) (port string, err e
|
||||
if len(parts) != 2 {
|
||||
return "", fmt.Errorf("could not parse USB VID/PID pair %q", s)
|
||||
}
|
||||
vid, err := strconv.ParseUint(parts[1], 16, 16)
|
||||
vid, err := strconv.ParseUint(parts[0], 16, 16)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not parse USB vendor ID %q: %w", parts[1], err)
|
||||
}
|
||||
pid, err := strconv.ParseUint(parts[2], 16, 16)
|
||||
pid, err := strconv.ParseUint(parts[1], 16, 16)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("could not parse USB product ID %q: %w", parts[1], err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user