fn soft_check(data: &[u8]) -> Result<Vec<u8>, Error> {
    let decompress = Decompress::new_mem(data)?;
    let mut rgb = decompress.rgb()?;
    // Yikes. That method is unsound. But we don't care, we just don't use it with UB.
    let lines = rgb.read_scanlines::<[u8; 3]>()
        .ok_or_else(|| Error::from(std::io::ErrorKind::Other))?;
    let lines = unsafe {
        core::slice::from_raw_parts(
            lines.as_ptr() as *const u8,
            lines.len()*3)
    }.to_owned();
    Ok(lines)
}
// Try to check the image, never panic.
Try to check the image, never panic.
Try to check the image never panic .
fn soft_check(data: &[u8]) -> Result<Vec<u8>, Error> {
    let decompress = Decompress::new_mem(data)?;
    let mut rgb = decompress.rgb()?;
    // Yikes. That method is unsound. But we don't care, we just don't use it with UB.
    let lines = rgb.read_scanlines::<[u8; 3]>()
        .ok_or_else(|| Error::from(std::io::ErrorKind::Other))?;
    let lines = unsafe {
        core::slice::from_raw_parts(
            lines.as_ptr() as *const u8,
            lines.len()*3)
    }.to_owned();
    Ok(lines)
}
fn soft_check ( data : & [ u8 ] ) -> Result < Vec < u8 > , Error > { let decompress = Decompress :: new_mem ( data ) ? ; let mut rgb = decompress . rgb ( ) ? ; // Yikes. That method is unsound. But we don't care, we just don't use it with UB. let lines = rgb . read_scanlines :: < [ u8 ; 3 ] > ( ) . ok_or_else ( | | Error :: from ( std :: io :: ErrorKind :: Other ) ) ? ; let lines = unsafe { core :: slice :: from_raw_parts ( lines . as_ptr ( ) as * const u8 , lines . len ( ) * 3 ) } . to_owned ( ) ; Ok ( lines ) }
Try to check the image, never panic.
Try to check the image never panic .
data
&[u8]
data
&[u8]