From 13868508386208f5a1a43b6c17991ad6f3652fea Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 12 Jun 2020 10:18:19 +0200 Subject: [PATCH] Use unused attribute for _dummy The (void)_dummy is apparently considered a read of an uninitialized variable. As it is a _Bool now, which has trap representations, this is no longer considered legal and results in somewhat odd ubsan warnings of the form: runtime error: load of value 0, which is not a valid value for type 'zend_bool' (aka 'bool') --- Zend/zend_API.h | 3 +-- ext/sqlite3/sqlite3.c | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Zend/zend_API.h b/Zend/zend_API.h index ae391d98e5..8ed0e20871 100644 --- a/Zend/zend_API.h +++ b/Zend/zend_API.h @@ -1253,7 +1253,7 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num zval *_real_arg, *_arg = NULL; \ zend_expected_type _expected_type = Z_EXPECTED_LONG; \ char *_error = NULL; \ - zend_bool _dummy; \ + ZEND_ATTRIBUTE_UNUSED zend_bool _dummy; \ zend_bool _optional = 0; \ int _error_code = ZPP_ERROR_OK; \ ((void)_i); \ @@ -1261,7 +1261,6 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num ((void)_arg); \ ((void)_expected_type); \ ((void)_error); \ - ((void)_dummy); \ ((void)_optional); \ \ do { \ diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c index c309d5d545..895a1b0cfd 100644 --- a/ext/sqlite3/sqlite3.c +++ b/ext/sqlite3/sqlite3.c @@ -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) { - zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s", sqlite3_errmsg(db_obj->db)); sqlite3_close(db_obj->db); + zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s", sqlite3_errmsg(db_obj->db)); RETURN_THROWS(); } } -- 2.40.0