Skip to content

Commit

Permalink
Merge pull request #670 from mattn/close-db
Browse files Browse the repository at this point in the history
Close db even if sqlite3_open_v2 return non-zero.
  • Loading branch information
mattn committed Dec 7, 2018
2 parents 6a9185d + 8f4ea28 commit e924752
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sqlite3.go
Expand Up @@ -1342,6 +1342,9 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
mutex|C.SQLITE_OPEN_READWRITE|C.SQLITE_OPEN_CREATE,
nil)
if rv != 0 {
if db != nil {
C.sqlite3_close_v2(db)
}
return nil, Error{Code: ErrNo(rv)}
}
if db == nil {
Expand Down

0 comments on commit e924752

Please sign in to comment.