Skip to content

Commit fc03fa9

Browse files
committed
close connection when got errors in Open
1 parent 866c329 commit fc03fa9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sqlite3.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,19 +609,22 @@ func (d *SQLiteDriver) Open(dsn string) (driver.Conn, error) {
609609

610610
rv = C.sqlite3_busy_timeout(db, C.int(busyTimeout))
611611
if rv != C.SQLITE_OK {
612+
conn.Close()
612613
return nil, Error{Code: ErrNo(rv)}
613614
}
614615

615616
conn := &SQLiteConn{db: db, loc: loc, txlock: txlock}
616617

617618
if len(d.Extensions) > 0 {
618619
if err := conn.loadExtensions(d.Extensions); err != nil {
620+
conn.Close()
619621
return nil, err
620622
}
621623
}
622624

623625
if d.ConnectHook != nil {
624626
if err := d.ConnectHook(conn); err != nil {
627+
conn.Close()
625628
return nil, err
626629
}
627630
}

0 commit comments

Comments
 (0)