Close db even if sqlite3_open_v2 return non-zero.

This commit is contained in:
Yasuhiro Matsumoto 2018-12-07 13:13:49 +09:00
parent 6a9185d7b1
commit 8f4ea282cf
No known key found for this signature in database
GPG Key ID: 622DE34DC490584B
1 changed files with 3 additions and 0 deletions

View File

@ -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 {