Skip to content

sqlite3: fix internal return type violation in escapeString()#22026

Open
ndossche wants to merge 1 commit into
php:PHP-8.4from
ndossche:clesss-37
Open

sqlite3: fix internal return type violation in escapeString()#22026
ndossche wants to merge 1 commit into
php:PHP-8.4from
ndossche:clesss-37

Conversation

@ndossche
Copy link
Copy Markdown
Member

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.

Found by a static-dynamic analyser I'm developing.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant