]> granicus.if.org Git - php/commitdiff
Revert accidental change
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 12 Jun 2020 09:34:01 +0000 (11:34 +0200)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 12 Jun 2020 09:34:01 +0000 (11:34 +0200)
Not sure how this happened, but I seem to have reverted
2fd278bc211c2102422c8d8ce0905dfc43cb5c7f
as part of
13868508386208f5a1a43b6c17991ad6f3652fea.

Restore the change.

ext/sqlite3/sqlite3.c

index 895a1b0cfd739103b68975a4ef030184bfb6868f..c309d5d545e053cbcc2a2460f931907459bf43d6 100644 (file)
@@ -135,13 +135,13 @@ PHP_METHOD(SQLite3, open)
 
        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));
 #else
                                db_obj->db ? sqlite3_errmsg(db_obj->db) : "");
 #endif
+               sqlite3_close(db_obj->db);
                if (fullpath != filename) {
                        efree(fullpath);
                }
@@ -151,8 +151,8 @@ PHP_METHOD(SQLite3, open)
 #ifdef 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));
+                       sqlite3_close(db_obj->db);
                        RETURN_THROWS();
                }
        }