Skip to content

fix(rust: builder): add lifetime bounds to finish methods#8750

Open
dallasmarlow wants to merge 2 commits intogoogle:masterfrom
dallasmarlow:rust-finish-lifetime-fix
Open

fix(rust: builder): add lifetime bounds to finish methods#8750
dallasmarlow wants to merge 2 commits intogoogle:masterfrom
dallasmarlow:rust-finish-lifetime-fix

Conversation

@dallasmarlow
Copy link
Copy Markdown

This change addresses a reported issue where a FlatBufferBuilder could be finished with a WIPOffset created by a different builder.

Calling builder1.finish(offset_from_builder2) would compile but result in a runtime panic or data corruption, as the offset is meaningless in builder1's buffer.

The fix enforces the builder's lifetime ('fbb) on the generic type T of the WIPOffset in all finish methods (finish, finish_minimal, finish_size_prefixed, and finish_with_opts).

#8698

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Oct 31, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions Bot added the rust label Oct 31, 2025
@dallasmarlow dallasmarlow force-pushed the rust-finish-lifetime-fix branch from 9f794ee to 57a9222 Compare October 31, 2025 15:02
@dallasmarlow dallasmarlow force-pushed the rust-finish-lifetime-fix branch from a3134b3 to 002656f Compare November 20, 2025 02:21
@jtdavis777
Copy link
Copy Markdown
Collaborator

this seems good to me (as a rust n00b) -- is there a way we can write a regression test against this as part of this PR?

@jtdavis777 jtdavis777 self-requested a review December 3, 2025 04:28
@jtdavis777 jtdavis777 added the waiting-for-update This PR is waiting for a change from the author or contributors before it is ready for merge label Dec 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust waiting-for-update This PR is waiting for a change from the author or contributors before it is ready for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust: Builder should only be able to finish messages created by itself at compile time.

2 participants