flatbuffers icon indicating copy to clipboard operation
flatbuffers copied to clipboard

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

Open dallasmarlow opened this issue 1 month ago • 2 comments

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).

https://github.com/google/flatbuffers/issues/8698

dallasmarlow avatar Oct 31 '25 14:10 dallasmarlow

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.

google-cla[bot] avatar Oct 31 '25 14:10 google-cla[bot]

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 avatar Dec 03 '25 04:12 jtdavis777