rc = sqlite3_open_v2(fullpath, &(db_obj->db), flags, NULL);
if (rc != SQLITE_OK) {
+ sqlite3_close(db_obj->db);
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s",
#ifdef HAVE_SQLITE3_ERRSTR
db_obj->db ? sqlite3_errmsg(db_obj->db) : sqlite3_errstr(rc));
#if SQLITE_HAS_CODEC
if (encryption_key_len > 0) {
if (sqlite3_key(db_obj->db, encryption_key, encryption_key_len) != SQLITE_OK) {
+ sqlite3_close(db_obj->db);
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s", sqlite3_errmsg(db_obj->db));
return;
}