From ff0e3df948be7c50c8e05bb3071e4d822bf6e203 Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Sat, 21 Jul 2018 00:37:57 -0400 Subject: [PATCH] Revert "Make cfzlib the default on platforms that support it" This reverts commit 2702145f3fac82d7e1ce6c3344db6044dff983e1. cfzlib seems to have a MASSIVE memory leak in it. Trying to use it when processing many files at once will cause your system to run out of memory. Closes #125 --- .travis.yml | 2 +- Cargo.toml | 4 +++- README.md | 2 +- README.template.md | 2 +- src/deflate/mod.rs | 9 +++++++-- src/lib.rs | 1 + 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index bd1a2cb6..682b7737 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ matrix: env: TARGET=x86_64-apple-darwin cache: cargo - os: linux - rust: 1.27.0 + rust: 1.24.0 env: TARGET=x86_64-unknown-linux-gnu cache: cargo - os: linux diff --git a/Cargo.toml b/Cargo.toml index c32376ae..03df815a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,6 +48,7 @@ optional = true version = "1.0.1" [dependencies.cloudflare-zlib-sys] +optional = true version = "^0.1.2" [dependencies.image] @@ -62,10 +63,11 @@ binary = [ ] default = ["binary", "parallel"] parallel = ["rayon"] +cfzlib = ["cloudflare-zlib-sys"] dev = [ "nightly-binary", ] -nightly = [] +nightly = ["cfzlib"] nightly-binary = [ "binary", "nightly", diff --git a/README.md b/README.md index 870de708..88a5b808 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ cargo build --release cp target/release/oxipng /usr/local/bin ``` -The current minimum supported Rust version is **1.27.0**. Oxipng may compile on earlier versions of Rust, +The current minimum supported Rust version is **1.24.0**. Oxipng may compile on earlier versions of Rust, but there is no guarantee. Oxipng follows Semantic Versioning. diff --git a/README.template.md b/README.template.md index f7f3a1f4..9f5e020e 100644 --- a/README.template.md +++ b/README.template.md @@ -26,7 +26,7 @@ cargo build --release cp target/release/oxipng /usr/local/bin ``` -The current minimum supported Rust version is **1.27.0**. Oxipng may compile on earlier versions of Rust, +The current minimum supported Rust version is **1.24.0**. Oxipng may compile on earlier versions of Rust, but there is no guarantee. Oxipng follows Semantic Versioning. diff --git a/src/deflate/mod.rs b/src/deflate/mod.rs index 2b4ef6e4..b24b7815 100644 --- a/src/deflate/mod.rs +++ b/src/deflate/mod.rs @@ -21,13 +21,17 @@ pub fn deflate( zw: u8, max_size: &AtomicMin, ) -> Result, PngError> { - if is_cfzlib_supported() { - return cfzlib_deflate(data, zc, zs, zw, max_size); + #[cfg(feature = "cfzlib")] + { + if is_cfzlib_supported() { + return cfzlib_deflate(data, zc, zs, zw, max_size); + } } miniz_stream::compress_to_vec_oxipng(data, zc, zw.into(), zs.into(), max_size) } +#[cfg(feature = "cfzlib")] fn is_cfzlib_supported() -> bool { #[cfg(target_arch = "x86_64")] { @@ -44,6 +48,7 @@ fn is_cfzlib_supported() -> bool { false } +#[cfg(feature = "cfzlib")] pub fn cfzlib_deflate( data: &[u8], level: u8, diff --git a/src/lib.rs b/src/lib.rs index 553b7f2a..eb1ee759 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ extern crate bit_vec; extern crate byteorder; +#[cfg(feature = "cfzlib")] extern crate cloudflare_zlib_sys; extern crate crc; extern crate image;