sqlite: fix error checks for column retrieval#22045
Open
ndossche wants to merge 1 commit into
Open
Conversation
These can return NULL on OOM. And for blobs, it can return NULL for empty blobs (so *no* failure, just an edge case). Passing NULL to memcpy is UB, so we have to check for a NULL pointer there to avoid UB.
Member
|
that falls into "defensive programming" IMHO. How likely ? not sure it belongs to PHP-8.4 ; if Saki says otherwise I won't object. |
Member
Author
At least the empty blob case should be easily hittable in production, which can cause UB in the memcpy path when the string initializes. The OOM checks are defensive. |
Member
|
ok that s a valid point. for sure the changes are correct to me :) |
devnexen
approved these changes
May 15, 2026
Member
devnexen
left a comment
There was a problem hiding this comment.
I was a bit on the fence with some subtle changes here and there but I do not object for 8.4
Member
Author
|
I can also split this PR into 2: one for the empty blob; and one for the OOM checks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These can return NULL on OOM.
And for blobs, it can return NULL for empty blobs (so no failure, just an edge case). Passing NULL to memcpy is UB, so we have to check for a NULL pointer there to avoid UB.
Found by a static-dynamic analyser I'm developing.