Skip to content

Reject overflowing hash map capacities#577

Open
Old-Ding wants to merge 1 commit into
ros2:rollingfrom
Old-Ding:codex/fix-hash-map-capacity-overflow
Open

Reject overflowing hash map capacities#577
Old-Ding wants to merge 1 commit into
ros2:rollingfrom
Old-Ding:codex/fix-hash-map-capacity-overflow

Conversation

@Old-Ding

Copy link
Copy Markdown

Summary

  • preserve an overflowing power-of-two rounding result instead of silently converting it to capacity 1
  • reject zero or overflowing bucket-array capacities in the shared allocation path used by initialization and growth
  • allocate the bucket array using the actual rcutils_array_list_t element size

Testing

  • added focused tests for rounding overflow and bucket-array size overflow
  • linked a focused probe against origin/rolling: SIZE_MAX returned success with initialized=1
  • linked the same probe against this change: returned RCUTILS_RET_BAD_ALLOC with initialized=0
  • compiled src/hash_map.c as C11 with Zig using -Wall -Wextra -Werror
  • git diff --check

Reject capacities that wrap while rounding or overflow the bucket
array allocation. Use the bucket element type for the allocation size.

Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
@mergify

mergify Bot commented Jul 11, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant