image
image copied to clipboard
InsufficientMemory error while trying to decode
This happens in random pngs, like this
Expected
Decoded png
Actual behaviour
Err(Limits(LimitError { kind: InsufficientMemory }))
Reproduction steps
use std::io::Read;
fn main() {
let path_to_file = "./broken.png";
let mut f = std::fs::File::open(path_to_file).expect("no file found");
let metadata = std::fs::metadata(&path_to_file).expect("unable to read metadata");
let mut buffer = vec![0; metadata.len() as usize];
f.read(&mut buffer).expect("buffer overflow");
let format = image::guess_format(&buffer).unwrap();
let mut reader = image::io::Reader::with_format(std::io::Cursor::new(buffer), format);
reader.no_limits();
let im = reader.decode().unwrap();
}
I also have that bug. Here's more info with wallpapers that fail https://github.com/danyspin97/wpaperd/issues/21#issue-1393401394
This issue hasn't been fixed, please reopen.
I looked into this some more. Seems that the original image contains an 18MB (!) text chunk before the image data, and the png crate has a hardcoded limit for such chunks.
So, most large but "normal" PNGs should work with the new limits support, but unfortunately more work is required to handle this specific case
@fintelia the issue was resolved https://github.com/danyspin97/wpaperd/issues/21#issuecomment-1994461074 and it works now.