Skip to content

Commit

Permalink
fix nil pointer dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
ynovytskyy authored and imiric committed Apr 28, 2023
1 parent 5910271 commit db814be
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ func (*SQL) Open(database string, connectionString string) (*dbsql.DB, error) {
// providing results as a slice of KeyValue instance(s) if available.
func (*SQL) Query(db *dbsql.DB, query string, args ...interface{}) ([]KeyValue, error) {
rows, err := db.Query(query, args...)
defer func() {
_ = rows.Close()
}()
if err != nil {
return nil, err
}

defer func() {
_ = rows.Close()
}()
if rows.Err() != nil {
return nil, rows.Err()
}
Expand Down

0 comments on commit db814be

Please sign in to comment.