Fix various issues reported by the UB sanitizers
Most of these involved left shifting a negative number, which is technically undefined (although every modern compiler I'm aware of will implement this by treating the signed integer as a 2's complement unsigned integer-- the LEFT_SHIFT() macro just makes this behavior explicit in order to shut up ubsan.) This also fixes a couple of non-issues in the entropy codecs, whereby the sanitizer reported an out-of-bounds index in the 4th argument of jpeg_make_d_derived_tbl(). In those cases, the index was actually out of bounds (caused by a malformed JPEG image), but jpeg_make_d_derived_tbl() would have caught the error and aborted prior to actually using the invalid address. Here again, the fix was to make our intentions explicit so as to shut up ubsan.
This commit is contained in:
@@ -306,7 +306,7 @@ decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
/* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */
|
||||
(*block)[0] = (JCOEF) (entropy->last_dc_val[ci] << cinfo->Al);
|
||||
(*block)[0] = (JCOEF) LEFT_SHIFT(entropy->last_dc_val[ci], cinfo->Al);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
Reference in New Issue
Block a user