Skip to content

fix: reject excessive AllocRingBuffer allocations#149

Open
Sieger9303 wants to merge 1 commit into
NULLx76:mainfrom
Sieger9303:fix-alloc-ringbuffer-large-allocation
Open

fix: reject excessive AllocRingBuffer allocations#149
Sieger9303 wants to merge 1 commit into
NULLx76:mainfrom
Sieger9303:fix-alloc-ringbuffer-large-allocation

Conversation

@Sieger9303
Copy link
Copy Markdown

Fixes #148 .

Hi, thanks for maintaining this crate.

AllocRingBuffer::new allocates a heap buffer based on the requested capacity rounded up to the next power of two. Very large capacities can produce a valid layout while still requesting an impractically large allocation, which can lead to resource exhaustion under tools such as Miri.

This PR adds a lightweight upper-bound check on the computed allocation size before calling the allocator. The public API shape is unchanged; excessive capacities now fail predictably with a Rust panic instead of reaching the raw allocation path.

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.

Potential soundnessissue in AllocRingBuffer::new for very large capacities

1 participant