From 9c18e832ceaedba4bce028703887955797f6c7d4 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Thu, 1 Jan 2015 17:46:14 +0100 Subject: [PATCH] Fixed unchecked array access --- serial_unix.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/serial_unix.go b/serial_unix.go index 98f8c71..edb1fac 100644 --- a/serial_unix.go +++ b/serial_unix.go @@ -10,6 +10,7 @@ package serial // import "go.bug.st/serial" import "io/ioutil" import "regexp" +import "strings" import "syscall" import "unsafe" @@ -116,7 +117,7 @@ func GetPortsList() ([]string, error) { portName := devFolder + "/" + f.Name() // Check if serial port is real or is a placeholder serial port "ttySxx" - if f.Name()[:4] == "ttyS" { + if strings.HasPrefix(f.Name(), "ttyS") { port, err := OpenPort(portName, &Mode{}) if err != nil { serr, ok := err.(*SerialPortError)