Skip to content

Fix uint16_t capacity truncation bug in ExtensionSet::GrowCapacity - #28987

Merged
copybara-service[bot] merged 1 commit into
mainfrom
test_958067520
Aug 3, 2026
Merged

Fix uint16_t capacity truncation bug in ExtensionSet::GrowCapacity#28987
copybara-service[bot] merged 1 commit into
mainfrom
test_958067520

Conversation

@copybara-service

Copy link
Copy Markdown

Fix uint16_t capacity truncation bug in ExtensionSet::GrowCapacity

In ExtensionSet::GrowCapacity, auto new_flat_capacity was deduced as uint16_t from flat_capacity_. When merging a large extension set (>2**16 elements), quadrupling new_flat_capacity (16384 * 4 = 65536) wrapped back to 0 in uint16_t, causing an infinite loop.

This change explicitly sets new_flat_capacity type to size_t to prevent truncation. A unit test MergeLargeExtensionSetToEmpty is added to extension_set_unittest.cc to cover this case.

In ExtensionSet::GrowCapacity, auto new_flat_capacity was deduced as uint16_t from flat_capacity_. When merging a large extension set (>2**16 elements), quadrupling new_flat_capacity (16384 * 4 = 65536) wrapped back to 0 in uint16_t, causing an infinite loop.

This change explicitly sets new_flat_capacity type to size_t to prevent truncation. A unit test MergeLargeExtensionSetToEmpty is added to extension_set_unittest.cc to cover this case.

PiperOrigin-RevId: 958634496
@copybara-service
copybara-service Bot merged commit 42e27e0 into main Aug 3, 2026
@copybara-service
copybara-service Bot deleted the test_958067520 branch August 3, 2026 23:21
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