Skip to content

fix: guard TopicPartitionList capacity#836

Open
Sieger9303 wants to merge 1 commit into
fede1024:masterfrom
Sieger9303:fix-topic-partition-list-capacity
Open

fix: guard TopicPartitionList capacity#836
Sieger9303 wants to merge 1 commit into
fede1024:masterfrom
Sieger9303:fix-topic-partition-list-capacity

Conversation

@Sieger9303
Copy link
Copy Markdown

Fixes #826.

Hi, thanks for maintaining this crate.

TopicPartitionList::with_capacity accepts a usize, but the underlying librdkafka API takes the capacity as an i32. Previously, values larger than i32::MAX were silently narrowed with capacity as i32, which could lead to surprising behavior, including very large allocation attempts for some inputs.

This PR adds an explicit upper-bound check before the cast and documents the panic condition. This keeps the existing API unchanged while making oversized capacities fail predictably in Rust before calling into librdkafka.

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 OOM / large allocation issue in TopicPartitionList::with_capacity(usize)

1 participant