From 6f47e5a8db62038c88eb38cb81221e4d1ae60f97 Mon Sep 17 00:00:00 2001 From: Michael Adams Date: Wed, 10 Jan 2024 21:50:31 -0800 Subject: [PATCH] Fixes #368. Added a (previously-missing) range check on the intermediate layer rates in the JPC encoder. Added another image to the test set. --- data/test/good/368_poc_min.pnm | 1 + src/libjasper/jpc/jpc_enc.c | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 data/test/good/368_poc_min.pnm diff --git a/data/test/good/368_poc_min.pnm b/data/test/good/368_poc_min.pnm new file mode 100644 index 00000000..c6d3a826 --- /dev/null +++ b/data/test/good/368_poc_min.pnm @@ -0,0 +1 @@ +P413 1 30 \ No newline at end of file diff --git a/src/libjasper/jpc/jpc_enc.c b/src/libjasper/jpc/jpc_enc.c index 64f8aa51..041c030a 100644 --- a/src/libjasper/jpc/jpc_enc.c +++ b/src/libjasper/jpc/jpc_enc.c @@ -566,6 +566,14 @@ static jpc_enc_cp_t *cp_create(const char *optstr, jas_image_t *image) jas_logwarnf("warning: invalid intermediate layer rates specifier ignored (%s)\n", jas_tvparser_getval(tvp)); } + /* Ensure that the intermediate layer rates are nonnegative. */ + for (i = 0; i < numilyrrates; ++i) { + if (ilyrrates[i] < 0) { + jas_logerrorf( + "intermediate layer rate must be nonnegative\n"); + goto error; + } + } break; case OPT_JP2OVERHEAD: