Skip to content

Commit 1386850

Browse files
committed
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')
1 parent f691693 commit 1386850

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Zend/zend_API.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,15 +1253,14 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num
12531253
zval *_real_arg, *_arg = NULL; \
12541254
zend_expected_type _expected_type = Z_EXPECTED_LONG; \
12551255
char *_error = NULL; \
1256-
zend_bool _dummy; \
1256+
ZEND_ATTRIBUTE_UNUSED zend_bool _dummy; \
12571257
zend_bool _optional = 0; \
12581258
int _error_code = ZPP_ERROR_OK; \
12591259
((void)_i); \
12601260
((void)_real_arg); \
12611261
((void)_arg); \
12621262
((void)_expected_type); \
12631263
((void)_error); \
1264-
((void)_dummy); \
12651264
((void)_optional); \
12661265
\
12671266
do { \

ext/sqlite3/sqlite3.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ PHP_METHOD(SQLite3, open)
135135

136136
rc = sqlite3_open_v2(fullpath, &(db_obj->db), flags, NULL);
137137
if (rc != SQLITE_OK) {
138+
sqlite3_close(db_obj->db);
138139
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s",
139140
#ifdef HAVE_SQLITE3_ERRSTR
140141
db_obj->db ? sqlite3_errmsg(db_obj->db) : sqlite3_errstr(rc));
141142
#else
142143
db_obj->db ? sqlite3_errmsg(db_obj->db) : "");
143144
#endif
144-
sqlite3_close(db_obj->db);
145145
if (fullpath != filename) {
146146
efree(fullpath);
147147
}
@@ -151,8 +151,8 @@ PHP_METHOD(SQLite3, open)
151151
#ifdef SQLITE_HAS_CODEC
152152
if (encryption_key_len > 0) {
153153
if (sqlite3_key(db_obj->db, encryption_key, encryption_key_len) != SQLITE_OK) {
154-
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s", sqlite3_errmsg(db_obj->db));
155154
sqlite3_close(db_obj->db);
155+
zend_throw_exception_ex(zend_ce_exception, 0, "Unable to open database: %s", sqlite3_errmsg(db_obj->db));
156156
RETURN_THROWS();
157157
}
158158
}

0 commit comments

Comments
 (0)