Repository navigation
Conversation
…ails odbc_prepare() set conn_ptr before describing the parameters but registered the result in conn->results only afterwards. When SQLDescribeParam() failed, the error branch freed param_info, then the object destructor freed it again in odbc_result_free() and deleted index 0 from conn->results, unregistering whichever live result held that slot. Register the result as soon as conn_ptr is set, as the other result-producing functions do, and release it through odbc_result_free() on failure. Fixes phpGH-25036
NattyNarwhal
approved these changes
Oct 29, 2026
NattyNarwhal
left a comment
Member
There was a problem hiding this comment.
Looks correct. The eager use of the implicit return_value (and mixing it with result unwrapped from that) I think makes this function a bit more confusing looking than it should be, but can clean that up in a followup PR.
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.
odbc_prepare()now registers results before describing parameters and releases them through odbc_result_free() when SQLDescribeParam() fails, preventing a double free and removal of another live result from the connection. Reported with the Windows {SQL Server} driver; verified locally with psqlODBC and PostgreSQL 16, including Valgrind.Fixes GH-25036