aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jdmarker.c7
-rw-r--r--jdphuff.c1
-rw-r--r--jquant2.c2
3 files changed, 7 insertions, 3 deletions
diff --git a/jdmarker.c b/jdmarker.c
index a19219f..c8771bc 100644
--- a/jdmarker.c
+++ b/jdmarker.c
@@ -478,14 +478,15 @@ get_dht (j_decompress_ptr cinfo)
if (index & 0x10) { /* AC table definition */
index -= 0x10;
+ if (index < 0 || index >= NUM_HUFF_TBLS)
+ ERREXIT1(cinfo, JERR_DHT_INDEX, index);
htblptr = &cinfo->ac_huff_tbl_ptrs[index];
} else { /* DC table definition */
+ if (index < 0 || index >= NUM_HUFF_TBLS)
+ ERREXIT1(cinfo, JERR_DHT_INDEX, index);
htblptr = &cinfo->dc_huff_tbl_ptrs[index];
}
- if (index < 0 || index >= NUM_HUFF_TBLS)
- ERREXIT1(cinfo, JERR_DHT_INDEX, index);
-
if (*htblptr == NULL)
*htblptr = jpeg_alloc_huff_table((j_common_ptr) cinfo);
diff --git a/jdphuff.c b/jdphuff.c
index 2267809..fa97aab 100644
--- a/jdphuff.c
+++ b/jdphuff.c
@@ -198,6 +198,7 @@ start_pass_phuff_decoder (j_decompress_ptr cinfo)
* On some machines, a shift and add will be faster than a table lookup.
*/
+#define AVOID_TABLES
#ifdef AVOID_TABLES
#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x))
diff --git a/jquant2.c b/jquant2.c
index 9b060e5..d994470 100644
--- a/jquant2.c
+++ b/jquant2.c
@@ -513,6 +513,8 @@ compute_color (j_decompress_ptr cinfo, boxptr boxp, int icolor)
}
}
+ if (total == 0)
+ return;
cinfo->colormap[0][icolor] = (JSAMPLE) ((c0total + (total>>1)) / total);
cinfo->colormap[1][icolor] = (JSAMPLE) ((c1total + (total>>1)) / total);
cinfo->colormap[2][icolor] = (JSAMPLE) ((c2total + (total>>1)) / total);