google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library

Home Page:https://flatbuffers.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect CreateUninitializedVector documentation [C++]

23scurtu opened this issue · comments

The documentation for CreateUninitializedVector seems to be incorrect. Particularly this line:

Write the data any time later to the returned buffer pointer buf

buf can be invalidated by subsequent calls to FlatBufferBuilder methods. For example, if calling CreateUninitializedVector twice such as when creating a flatbuffer that contains two vectors, the first buf may be invalidated if a reallocation is triggered inside CreateUninitializedVector. This natural usage easily leads to heap corruption. At the very least, the documentation for both CreateUninitializedVector [1/2] and [2/2] should be changed to have warnings about buf's invalidation.

Thanks.

buf can be invalidated by subsequent calls to FlatBufferBuilder methods.

What can I do if I want to create a flatbuffer with two vectors???
(The documentation still does not appear to have these warnings in place).

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

Commenting to prevent this issue from being closed. The documentation has still not been updated. Somebody please fix this, its been 6 months.

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.