Skip to main content

set_array_alloc_chunk

Function set_array_alloc_chunk 

Source
pub fn set_array_alloc_chunk(n: usize)
Expand description

Set the maximum number of array elements that will be pre-allocated when decoding an array.

This caps the initial Vec::reserve call so that a maliciously crafted stream that claims a huge varsize length cannot cause an out-of-memory condition before any data is actually read. The vector grows naturally as real elements arrive.

The default is 1 000. A value of 0 disables pre-allocation entirely.