Increase icc decompression buffer size
This commit is contained in:
parent
7d52fd66d0
commit
ce8bdd0981
1 changed files with 5 additions and 5 deletions
|
|
@ -263,11 +263,11 @@ pub fn extract_icc(iccp: &Chunk, max_size: Option<usize>) -> Option<Vec<u8>> {
|
||||||
if compression_method != 0 {
|
if compression_method != 0 {
|
||||||
return None; // The profile is supposed to be compressed (method 0)
|
return None; // The profile is supposed to be compressed (method 0)
|
||||||
}
|
}
|
||||||
// The decompressed size is unknown so we have to guess the required buffer size
|
// Libdeflate works with a fixed size buffer. Since the decompressed size is unknown we have to
|
||||||
let mut out_size = compressed_data.len() * 2 + 1000;
|
// guess the required buffer size. We allow a fairly generous 10x factor with a minimum of 1000.
|
||||||
if let Some(max) = max_size {
|
let mut out_size = (compressed_data.len() * 10).max(1000);
|
||||||
out_size = out_size.min(max);
|
// For sanity, impose a default limit of 1MB.
|
||||||
}
|
out_size = out_size.min(max_size.unwrap_or(1_000_000));
|
||||||
match inflate(compressed_data, out_size) {
|
match inflate(compressed_data, out_size) {
|
||||||
Ok(icc) => Some(icc),
|
Ok(icc) => Some(icc),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue