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.
This commit is contained in:
Nora Dossche authored and GitHub committed 2026-05-15 12:05:10 +02:00
1 parent 0078a27630
commit cde32beade
1 file changed
+3
+3
View File
@@ -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();