summaryrefslogtreecommitdiff
path: root/jcmaster.c
diff options
context:
space:
mode:
authorThomas G. Lane <tgl@netcom.com>1998-03-27 00:00:00 +0000
committerDRC <information@libjpeg-turbo.org>2015-07-27 13:43:00 -0500
commit5ead57a34a398aa798f35bd7a6abad19b2e453e2 (patch)
tree28613ddc542c153d85afab078c9835864ed67f11 /jcmaster.c
parent489583f5165e05d37302e8eeec58104ea0109127 (diff)
The Independent JPEG Group's JPEG software v6b
Diffstat (limited to 'jcmaster.c')
-rw-r--r--jcmaster.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/jcmaster.c b/jcmaster.c
index c3e1ef5..aab4020 100644
--- a/jcmaster.c
+++ b/jcmaster.c
@@ -1,7 +1,7 @@
/*
* jcmaster.c
*
- * Copyright (C) 1991-1996, Thomas G. Lane.
+ * Copyright (C) 1991-1997, Thomas G. Lane.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@@ -185,8 +185,20 @@ validate_script (j_compress_ptr cinfo)
Al = scanptr->Al;
if (cinfo->progressive_mode) {
#ifdef C_PROGRESSIVE_SUPPORTED
+ /* The JPEG spec simply gives the ranges 0..13 for Ah and Al, but that
+ * seems wrong: the upper bound ought to depend on data precision.
+ * Perhaps they really meant 0..N+1 for N-bit precision.
+ * Here we allow 0..10 for 8-bit data; Al larger than 10 results in
+ * out-of-range reconstructed DC values during the first DC scan,
+ * which might cause problems for some decoders.
+ */
+#if BITS_IN_JSAMPLE == 8
+#define MAX_AH_AL 10
+#else
+#define MAX_AH_AL 13
+#endif
if (Ss < 0 || Ss >= DCTSIZE2 || Se < Ss || Se >= DCTSIZE2 ||
- Ah < 0 || Ah > 13 || Al < 0 || Al > 13)
+ Ah < 0 || Ah > MAX_AH_AL || Al < 0 || Al > MAX_AH_AL)
ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
if (Ss == 0) {
if (Se != 0) /* DC and AC together not OK */