Fix several potential overflow issues identified by the community.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user