Fix heap-buffer-overflow in Array deserialization#14
Merged
austinhartzheim merged 1 commit intocloudflare:mainfrom Feb 11, 2026
Merged
Fix heap-buffer-overflow in Array deserialization#14austinhartzheim merged 1 commit intocloudflare:mainfrom
austinhartzheim merged 1 commit intocloudflare:mainfrom
Conversation
0bd3661 to
e166092
Compare
e166092 to
142b301
Compare
silverfoxy
commented
Feb 10, 2026
| /// Returns the representation type of `CardinalityEstimator`. | ||
| #[inline] | ||
| pub(crate) fn representation(&self) -> Representation<P, W> { | ||
| pub(crate) fn representation(&self) -> Representation<'_, P, W> { |
Contributor
Author
There was a problem hiding this comment.
This makes clippy happy.
--> src/estimator.rs:98:34
|
98 | pub(crate) fn representation(&self) -> Representation<P, W> {
| ^^^^^ ^^^^^^^^^^^^^^^^^^^^ the same lifetime is hidden here
| |
| the lifetime is elided here
|
= help: the same lifetime is referred to in inconsistent ways, making the signature confusing
= note: `-D mismatched-lifetime-syntaxes` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(mismatched_lifetime_syntaxes)]`
help: use `'_` for type paths
|
98 | pub(crate) fn representation(&self) -> Representation<'_, P, W> {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes a bug where Array::from_vec and Array::From disagreed on capacity calculation, causing heap-buffer-overflow when deserializing with certain serializers (e.g., bincode)
I added simple regression test for the capacity mismatch issue.
The Bug
from_vec used cap = arr.len() while From assumed cap = len.next_power_of_two().
When deserializing 100 elements:
This affects serializers like bincode that create exact-capacity Vecs. serde_json accidentally masked the bug because push() doubles capacity.
The Fix
from_vec now resizes the Vec to len.next_power_of_two() before forgetting it, ensuring the allocation matches what From expects.