From 1518e678ba4b086153735890841e0e4fd38d85b1 Mon Sep 17 00:00:00 2001 From: "Kwabena W. Agyeman" Date: Sun, 27 Jan 2019 19:57:52 -0500 Subject: [PATCH] Fix wrong size calculation. --- src/omv/py/py_image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/omv/py/py_image.c b/src/omv/py/py_image.c index 9e81879de..0576e4b79 100644 --- a/src/omv/py/py_image.c +++ b/src/omv/py/py_image.c @@ -1114,7 +1114,7 @@ static mp_obj_t py_image_compress_for_ide(uint n_args, const mp_obj_t *args, mp_ uint8_t *buffer = fb_alloc_all(&size); image_t out = { .w=arg_img->w, .h=arg_img->h, .bpp=size, .data=buffer }; PY_ASSERT_FALSE_MSG(jpeg_compress(arg_img, &out, arg_q, false), "Out of Memory!"); - PY_ASSERT_TRUE_MSG(out.bpp <= image_size(arg_img), "Can't compress in place!"); + PY_ASSERT_TRUE_MSG(((((out.bpp * 8) + 5) / 6) + 2) <= image_size(arg_img), "Can't compress in place!"); uint8_t *ptr = arg_img->data; *ptr++ = 0xFE;