-
Notifications
You must be signed in to change notification settings - Fork 809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a count
-like combinator, without preallocation
#1459
Milestone
Comments
Additional notes:
|
I submitted PR #1545 to clamp |
|
jkugelman
added a commit
to jkugelman/nom
that referenced
this issue
Sep 12, 2022
jkugelman
added a commit
to jkugelman/nom
that referenced
this issue
Sep 13, 2022
jkugelman
added a commit
to jkugelman/nom
that referenced
this issue
Sep 13, 2022
- Fixes rust-bakery#1459 (comment) - Also change `clamp` to `min` so this works on Rust 2018 edition.
Geal
added a commit
that referenced
this issue
Dec 28, 2022
* Fix clamped capacity to be divided by element size - Fixes #1459 (comment) - Also change `clamp` to `min` so this works on Rust 2018 edition. * Update src/multi/mod.rs Co-authored-by: Geoffroy Couprie <geo.couprie@gmail.com> Co-authored-by: Geoffroy Couprie <contact@geoffroycouprie.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Currently,
count
usesVec::with_capacity
to preallocates theVec
(https://github.com/Geal/nom/blob/7.0.0/src/multi/mod.rs#L537).While this is best for performance, this makes the
count
combinator very fragile when using an untrusted count value: any large value will result in a immediate error (fuzzers love thecount
combinator!).I don't know if it's possible to check the allocation in
Vec
(stable API does not seem to allow it :/ ), but maybe adding an upper bound in a new combinator (count_max
) could be a workaround?Test case
Example test case:
Output (debug):
The text was updated successfully, but these errors were encountered: