From 2d6b6e8a9987386afe388e1cde859d0182445e63 Mon Sep 17 00:00:00 2001 From: Michael Adams Date: Sat, 27 Apr 2024 10:49:23 -0700 Subject: [PATCH] Fixes #383. Added some missing checks to the jas_heic_decode function in the HEIC codec. Added support for handling HEIC images in the run_test_1 script. Added a HEIC image to the test set. --- data/test/bad/383.heic | Bin 0 -> 7414 bytes src/libjasper/heic/heic_dec.c | 20 +++++++++++++++----- test/bin/run_test_1 | 10 ++++++++++ 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 data/test/bad/383.heic diff --git a/data/test/bad/383.heic b/data/test/bad/383.heic new file mode 100644 index 0000000000000000000000000000000000000000..f2f587956ed96f5352d6f30d20b7771e4bd35efa GIT binary patch literal 7414 zcmeHMcT`i&wm%d>l%|4wDB=;2A{-1wiWo$YUZsej2qA?;(nvz@y`zAlh*AVpL=Xf8 zL8OByMMObqQUwcw^3hA~iJ#vsZ{2m@d+Ysi|9E$=mCWopGqY#^X7AseOaK57!!dlR zcq{=8z``m?1e_9qPEmu^HzX_rl|CTZ0oVDd1O|!K2VjFg8U!K*&8o!2z&fk)H~B{m z5d8IocL1)OAy8>lxYQz0(G8?C82(`!KT^S z*kR=mfk4LnY-CL)1}j)rGiznA1tqvCv1LethHTCzS+#98$KVN zNS5(QMSFENk1iL)a&z0P^q80@IN5o7Mw?b{xN$tBSc;dQ8s+NTDoeNw@cCEhs0qcq zHeX&I2rPBphIYM^x%sW!W7WJm^)N+I&t?9=-6zT-KV}_t)9V614UP0D-SEAwRs*~r z76Ltury>%i<&I^`8Vj7zv>)%Tjc#*#!`3itBZf1QK?mIO_P^u5MJ%zh&y4*;t?zTs z__>*|T6H%nbo0T}(Sua?KPw*e-PePV9kxk#*hqIUF-VjC}By!?Ub({k>8uf8~;IfnGL z#jO*ZGB0YP1_saHwl$X%YP5J;#fezSiyjrKlAKPR&)}{a$q!XZ4s}Rv>_mMKxwt7w z4g6xyxOMi~73cc)P3vIKm-VS!ma(sc-lRX_Do}ef$*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Qy%+?D#TRfuBY*P6uRQsg$FLPRUr?yOXHb}w zSPTl`Ff`DM0^w!nnE-$R*#HP*i+QK?lS33xAt>U$V0as7lW^#35V7u96XX$)&Wj>q z;VeeSu~K#$O`jP|4uUq}gw|taFhq+7ArOlrEW#wpIzy1~IRF4ZBLxq@l!%3h1lGMZ z2Bwaj96=z5nFH?=6J7x9dN7lEu*$0ta$nS^kgwn-G}zH`!fY4rcz_ zO#jF5e-QX52(YjGlg9rKO*uL_`8mH{%GOSIFr@(YX#l2s_$>fS0YI3$Vc7!!yCNy@ zi!DQeby@)jx JAS_IMAGE_COORD_MAX || height > JAS_IMAGE_COORD_MAX) { + jas_logerrorf("image size too large\n"); goto error; } cmptparm.tlx = 0; @@ -290,6 +298,8 @@ jas_image_t *jas_heic_decode(jas_stream_t *in, const char *optstr) data[3 * width * y + 3 * x + cmptno]); } if (jas_image_writecmpt(image, cmptno, 0, y, width, 1, matrix)) { + jas_logerrorf("jas_image_writecmpt failed\n"); + goto error; } } } diff --git a/test/bin/run_test_1 b/test/bin/run_test_1 index 24cb9878..eb8172c7 100755 --- a/test/bin/run_test_1 +++ b/test/bin/run_test_1 @@ -46,10 +46,15 @@ has_jpg="$(is_supported_format jpg)" || \ panic "cannot determine if JPG is supported format" has_mif="$(is_supported_format mif)" || \ panic "cannot determine if MIF is supported format" +has_heic="$(is_supported_format heic)" || \ + panic "cannot determine if HEIF is supported format" if [ "$internal_testing_mode" -ne 0 -a "$has_mif" -eq 0 ]; then echo "warning: MIF support is missing" fi +if [ "$internal_testing_mode" -ne 0 -a "$has_heic" -eq 0 ]; then + echo "warning: HEIF support is missing" +fi if [ "$has_jpg" -eq 0 ]; then echo "warning: JPEG support is missing" fi @@ -70,6 +75,11 @@ for file in "$data_dir"/test/good/*.*; do skip=1 fi ;; + *.heic) + if [ "$has_heic" -eq 0 ]; then + skip=1 + fi + ;; *.txt) skip=1 ;;