Skip to content

Make TArray safer to use and update method name for consistency.#4483

Merged
edgchen1 merged 1 commit into
masterfrom
edgchen1/tarray_update
Jul 13, 2020
Merged

Make TArray safer to use and update method name for consistency.#4483
edgchen1 merged 1 commit into
masterfrom
edgchen1/tarray_update

Conversation

@edgchen1
Copy link
Copy Markdown
Contributor

Description
Update TArray:

  • make size_ and data_ data members private
  • rename GetCapacity() to Capacity() to be consistent (e.g., with Size())
  • add static_assert for trivially copyable T because it is copied with memcpy

Motivation and Context
The original potential issue was that size_ could be set to any value, including beyond the capacity of the TArray. This could result in out of bounds memory access. Now the invariant that size_ <= capacity is enforced.

@edgchen1 edgchen1 added the core runtime issues related to core runtime label Jul 10, 2020
@edgchen1 edgchen1 requested a review from weixingzhang July 10, 2020 21:56
@edgchen1 edgchen1 requested a review from a team as a code owner July 10, 2020 21:56
@edgchen1 edgchen1 merged commit c71c49a into master Jul 13, 2020
@edgchen1 edgchen1 deleted the edgchen1/tarray_update branch July 13, 2020 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core runtime issues related to core runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants