Fix division by zero
authormayeut <mayeut@users.noreply.github.com>
Sun, 8 May 2016 16:40:12 +0000 (18:40 +0200)
committermayeut <mayeut@users.noreply.github.com>
Sun, 8 May 2016 16:40:12 +0000 (18:40 +0200)
Fix uclouvain/openjpeg#733

src/lib/openjp2/tcd.c
tests/nonregression/test_suite.ctest.in

index 7ecd97cfef96e347b0f4a696ec61729e2eab63b3..b8cd3072b0beeb8338ed8503411a7f6a68d93c7e 100644 (file)
@@ -720,7 +720,8 @@ static INLINE OPJ_BOOL opj_tcd_init_tile(opj_tcd_t *p_tcd, OPJ_UINT32 p_tile_no,
                
                /* compute l_data_size with overflow check */
                l_data_size = (OPJ_UINT32)(l_tilec->x1 - l_tilec->x0);
-               if ((((OPJ_UINT32)-1) / l_data_size) < (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0)) {
+               /* issue 733, l_data_size == 0U, probably something wrong should be checked before getting here */
+               if ((l_data_size > 0U) && ((((OPJ_UINT32)-1) / l_data_size) < (OPJ_UINT32)(l_tilec->y1 - l_tilec->y0))) {
                        opj_event_msg(manager, EVT_ERROR, "Not enough memory for tile data\n");
                        return OPJ_FALSE;
                }
index f22a89f504157273d53413dad7a81a7137c5cdf7..c48f66b298814d6e956227ecdd5f5b5d5e1d9158 100644 (file)
@@ -557,3 +557,5 @@ opj_decompress -i @INPUT_NR_PATH@/basn6a08.jp2 -o @TEMP_PATH@/basn6a08_tif-15.ti
 !opj_decompress -i @INPUT_NR_PATH@/issue725.jp2 -o @TEMP_PATH@/issue725.png
 # issue 726
 opj_decompress -i @INPUT_NR_PATH@/issue726.j2k -o @TEMP_PATH@/issue726.png
+# issue 733
+!opj_decompress -i @INPUT_NR_PATH@/issue733.jp2 -o @TEMP_PATH@/issue733.png