diff options
Diffstat (limited to 'vendor/miniz_oxide/src/inflate')
-rw-r--r-- | vendor/miniz_oxide/src/inflate/mod.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/vendor/miniz_oxide/src/inflate/mod.rs b/vendor/miniz_oxide/src/inflate/mod.rs index 535392327..03b9dc988 100644 --- a/vendor/miniz_oxide/src/inflate/mod.rs +++ b/vendor/miniz_oxide/src/inflate/mod.rs @@ -151,14 +151,12 @@ fn decompress_to_vec_inner( } TINFLStatus::HasMoreOutput => { - // We need more space, so check if we can resize the buffer and do it. - let new_len = ret - .len() - .checked_add(out_pos) - .ok_or(TINFLStatus::HasMoreOutput)?; - if new_len > max_output_size { + // if the buffer has already reached the size limit, return an error + if ret.len() >= max_output_size { return Err(TINFLStatus::HasMoreOutput); - }; + } + // calculate the new length, capped at `max_output_size` + let new_len = ret.len().saturating_mul(2).min(max_output_size); ret.resize(new_len, 0); } |