Skip to content

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

Open
ndossche wants to merge 1 commit into
php:masterfrom
ndossche:clesss-37
Open

sqlite3: fix internal return type violation in escapeString()#22026
ndossche wants to merge 1 commit into
php:masterfrom
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.
@devnexen
Copy link
Copy Markdown
Member

is correct but not sure it fully qualify as bug fix ? master ?

@ndossche
Copy link
Copy Markdown
Member Author

is correct but not sure it fully qualify as bug fix ? master ?

Fine by me

Copy link
Copy Markdown
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but I do think it belongs to master.

@ndossche ndossche changed the base branch from PHP-8.4 to master May 13, 2026 18:41
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.

2 participants