Files
codeql/go/ql/src/InconsistentCode/MissingErrorCheck.go
2022-05-20 10:07:19 -07:00

18 lines
262 B
Go

package main
import (
"fmt"
"os"
)
func user(input string) {
ptr, err := os.Open(input)
// BAD: ptr is dereferenced before either it or `err` has been checked.
fmt.Printf("Opened %v\n", *ptr)
if err != nil {
fmt.Printf("Bad input: %s\n", input)
}
}