Skip to content

base64::decode_config excessive memory allocation #195

@dkomanov

Description

@dkomanov

According to the source code:

pub fn decode_config<T: AsRef<[u8]>>(input: T, config: Config) -> Result<Vec<u8>, DecodeError> {
    let mut buffer = Vec::<u8>::with_capacity(input.as_ref().len() * 4 / 3);

    decode_config_buf(input, config, &mut buffer).map(|_| buffer)
}

decode_config method allocates excessive amount of memory: len * 4 / 3 instead of (len + 3) * 3 / 4.

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions