Fix memory leak when sqlite3_open_v2 fails
authorHonglei Zhang <honglei.zhang@nokia.com>
Mon, 12 Mar 2012 14:52:25 +0000 (16:52 +0200)
committerQt by Nokia <qt-info@nokia.com>
Tue, 13 Mar 2012 20:11:55 +0000 (21:11 +0100)
commitdedd4a7a7ca9be18ed9fc958ea4da48c2f1fd82f
tree92101a5e6abce2c00246529942edc54b937d2c52
parent268f41ec70fd70d4aa44a5043d1a4e678df4c5b5
Fix memory leak when sqlite3_open_v2 fails

According to SQLite documentation, a database connection handle
is usually returned, even if an error occurs. This behavior has
caused Qt to leak memory when opening a database is failed. Now,
even if sqlite3_open_v2() does not return SQLITE_OK, Qt tries to
release SQLite database handle by calling sqlite3_close().

Task-number: QTBUG-15773
Change-Id: I6538e2897216828a9cfb95b7d4a5cec437aa6c28
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Reviewed-by: Andy Shaw <andy.shaw@digia.com>
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
src/sql/drivers/sqlite/qsql_sqlite.cpp