Repository navigation
Conversation
Clear rsr_self before Statement::statement member becomes invalid. The Rsr::rsr_self pointer was left dangling when Statement was freed before the Rsr, causing use-after-free when Rsr destructor accessed it. Added Statement destructor and explicit clear in freeClientData.
dand-oss
marked this pull request as ready for review
October 7, 2026 09:15
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.
When forced statement cleanup encounters an invalid attachment handle, Statement::release() can destroy the Statement while its Rsr remains alive. Rsr::rsr_self then points into the freed Statement; the later Rsr destructor reads that freed member. Clear the back-pointer when Statement relinquishes its handle and in the Statement destructor when a handle remains.
Independently reproduced on Linux x86-64 using the Firebird 5 ASan/UBSan debug build with system allocation enabled. A focused test compiled the actual remote/client/interface.cpp and linked the existing production client objects and libraries. The before/after sources differed only by the two fix hunks, with the same test entry point appended:
With the fix removed, ASan reports a heap-use-after-free in Rsr::~Rsr(): an 8-byte read from the Statement allocation freed by Remote::Statement::release(). With the fix applied, the same test exits 0 with no ASan/UBSan report. ASan used detect_leaks=0 and halt_on_error=1.
The current-master patch also passes GCC 16.2 C++20 syntax compilation and git diff --check. The runtime test exercises the production ownership and forced-cleanup path through fault injection; it is not an end-to-end WinGLUE session or a runtime test of master.