Enum gif::reader::MemoryLimit
source · pub enum MemoryLimit {
Unlimited,
Bytes(NonZeroU64),
}
Expand description
The maximum amount of memory the decoder is allowed to use for each frame
Variants§
Unlimited
Enforce no memory limit.
If you intend to process images from unknown origins this is a potentially dangerous constant to use, as your program could be vulnerable to decompression bombs. That is, malicious images crafted specifically to require an enormous amount of memory to process while having a disproportionately small file size.
The risks for modern machines are a bit smaller as the size of each frame cannot exceed 16GiB, but this is still a significant amount of memory.
Bytes(NonZeroU64)
Limit the amount of memory that can be used for a single frame to this many bytes.
It may not be enforced precisely due to allocator overhead and the decoder potentially allocating small auxiliary buffers, but it will precisely limit the size of the output buffer for each frame.
Implementations§
source§impl MemoryLimit
impl MemoryLimit
fn check_size(&self, size: usize) -> Result<(), DecodingError>
fn buffer_size( &self, color: ColorOutput, width: u16, height: u16, ) -> Option<usize>
Trait Implementations§
source§impl Clone for MemoryLimit
impl Clone for MemoryLimit
source§fn clone(&self) -> MemoryLimit
fn clone(&self) -> MemoryLimit
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more