fix openV2 handle leak, TLS leak, and misleading error on failed open

When sqlite3_open_v2 fails, the SQLite docs require the caller to close the handle it may have allocated. The previous code did not, leaking the sqlite3 struct and potentially VFS-level state.

Additionally, newConn did not close libc.TLS on the openV2 failure path, leaking C-heap memory.

Lastly, the error message was misleading: errstr called sqlite3_errmsg with c.db == 0 (not yet set), which always returns "out of memory", producing errors like "unable to open database file: out of memory (14)" regardless of the actual cause.

Fix all of those.

Merge request reports

Loading