Skip to content

Commit

Permalink
Fix replaced error handling in SQLite3Stmt::__construct
Browse files Browse the repository at this point in the history
The error handling is replaced using zend_replace_error_handling(), but
when SQLITE3_CHECK_INITIALIZED() returns early, the old error handling
isn't restored.

In the past, SQLITE3_CHECK_INITIALIZED() threw a warning when the check
failed. This was replaced a few years ago with an error exception. So we
can fix the bug by just removing the replacing error handling as it
accomplishes nothing anymore.

Closes GH-11607.
  • Loading branch information
nielsdos committed Jul 7, 2023
1 parent 0aaad46 commit 824d1f9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ PHP NEWS
- Standard:
. Fix serialization of RC1 objects appearing in object graph twice. (ilutov)

- SQLite3:
. Fix replaced error handling in SQLite3Stmt::__construct. (nielsdos)

06 Jul 2023, PHP 8.1.21

- CLI:
Expand Down
3 changes: 0 additions & 3 deletions ext/sqlite3/sqlite3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1820,7 +1820,6 @@ PHP_METHOD(SQLite3Stmt, __construct)
zval *db_zval;
zend_string *sql;
int errcode;
zend_error_handling error_handling;
php_sqlite3_free_list *free_item;

stmt_obj = Z_SQLITE3_STMT_P(object);
Expand All @@ -1831,9 +1830,7 @@ PHP_METHOD(SQLite3Stmt, __construct)

db_obj = Z_SQLITE3_DB_P(db_zval);

zend_replace_error_handling(EH_THROW, NULL, &error_handling);
SQLITE3_CHECK_INITIALIZED(db_obj, db_obj->initialised, SQLite3)
zend_restore_error_handling(&error_handling);

if (!ZSTR_LEN(sql)) {
RETURN_FALSE;
Expand Down

0 comments on commit 824d1f9

Please sign in to comment.