From 333fb2b5fef051ed56f234791e297922c7d6b326 Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Sun, 14 Jan 2024 23:30:22 -0800 Subject: [PATCH] ports/stm32: Error on jpeg geometry mismatch. --- src/omv/ports/stm32/jpeg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/omv/ports/stm32/jpeg.c b/src/omv/ports/stm32/jpeg.c index d491e8cf1..9382b8182 100644 --- a/src/omv/ports/stm32/jpeg.c +++ b/src/omv/ports/stm32/jpeg.c @@ -353,6 +353,10 @@ void jpeg_decompress(image_t *dst, image_t *src) { HAL_JPEG_Decode(&JPEG_state.jpeg_descr, JPEG_state.jpeg_descr.pJpegInBuffPtr, JPEG_state.in_data_len, temp, JPEG_OUTPUT_CHUNK_SIZE, JPEG_CODEC_TIMEOUT); + if ((src->w != JPEG_state.jpeg_descr.Conf.ImageWidth) || (src->h != JPEG_state.jpeg_descr.Conf.ImageHeight)) { + mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("JPEG Geometry does not match Image Object Geometry!")); + } + // Set handles for full decoding. HAL_JPEG_RegisterGetDataCallback(&JPEG_state.jpeg_descr, jpeg_decompress_get_data); HAL_JPEG_RegisterDataReadyCallback(&JPEG_state.jpeg_descr, jpeg_decompress_data_ready);