Commit cde32beadee for php.net
commit cde32beadeee04c16d8607266ea7586078fbc9df
Author: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Date: Fri May 15 12:05:10 2026 +0200
sqlite3: fix internal return type violation in escapeString() (#22026)
If this call fails due to an internal libsqlite3 error, then the
function will return NULL (as that's the default value set by the VM).
However, the function is marked with a non-nullable string return type.
Therefore this will result in a type violation and a fatal error in
debug mode.
Either we solve it by making the function nullable or throw.
I chose the latter as it is less of a footgun.
diff --git a/ext/sqlite3/sqlite3.c b/ext/sqlite3/sqlite3.c
index 8b69eca4206..d257703f17a 100644
--- a/ext/sqlite3/sqlite3.c
+++ b/ext/sqlite3/sqlite3.c
@@ -478,6 +478,9 @@ PHP_METHOD(SQLite3, escapeString)
if (ret) {
RETVAL_STRING(ret);
sqlite3_free(ret);
+ } else {
+ zend_throw_exception_ex(php_sqlite3_exception_ce, 0, "Unable to escape string");
+ RETURN_THROWS();
}
} else {
RETURN_EMPTY_STRING();