diff --git a/src/decoder/image.rs b/src/decoder/image.rs index c678da8..c525ed2 100644 --- a/src/decoder/image.rs +++ b/src/decoder/image.rs @@ -486,11 +486,11 @@ impl Image { } else if padding.0 > 0 && self.predictor == Predictor::FloatingPoint { // The floating point predictor shuffles the padding bytes into the encoded output, so // this case is handled specially when needed. + let mut encoded = vec![0u8; chunk_dimensions.0 * samples * byte_len]; for row in 0..(chunk_dimensions.1 - padding.1) { let row_start = row * output_width * samples; let row_end = row_start + (chunk_dimensions.0 - padding.0) * samples; - let mut encoded = vec![0u8; chunk_dimensions.0 * samples * byte_len]; reader.read_exact(&mut encoded)?; match buffer.subrange(row_start..row_end) { DecodingBuffer::F32(buf) => fp_predict_f32(&mut encoded, buf, samples), diff --git a/src/decoder/mod.rs b/src/decoder/mod.rs index 22face5..c4299af 100644 --- a/src/decoder/mod.rs +++ b/src/decoder/mod.rs @@ -416,7 +416,9 @@ fn fix_endianness_and_predict( DecodingBuffer::I16(buf) => rev_hpredict_nsamp(buf, samples), DecodingBuffer::I32(buf) => rev_hpredict_nsamp(buf, samples), DecodingBuffer::I64(buf) => rev_hpredict_nsamp(buf, samples), - DecodingBuffer::F32(_) | DecodingBuffer::F64(_) => unreachable!(), + DecodingBuffer::F32(_) | DecodingBuffer::F64(_) => { + unreachable!("Caller should have validated arguments. Please file a bug.") + } } } Predictor::FloatingPoint => { @@ -424,7 +426,7 @@ fn fix_endianness_and_predict( match image { DecodingBuffer::F32(buf) => fp_predict_f32(&mut buffer_copy, buf, samples), DecodingBuffer::F64(buf) => fp_predict_f64(&mut buffer_copy, buf, samples), - _ => unreachable!(), + _ => unreachable!("Caller should have validated arguments. Please file a bug."), } } Predictor::__NonExhaustive => unreachable!(),