summaryrefslogtreecommitdiff
path: root/third_party/libopenjpeg20/j2k.c
diff options
context:
space:
mode:
authorOliver Chang <ochang@chromium.org>2016-02-23 12:41:41 -0800
committerOliver Chang <ochang@chromium.org>2016-02-23 12:41:41 -0800
commitc145aeb2bf13ac408fc3e8233acca43d4251bbdc (patch)
treea19a2b6a918446a047826eef7302f8c40ee468d3 /third_party/libopenjpeg20/j2k.c
parent2c8fad44315db58f5b3222161dcb699691dca904 (diff)
downloadpdfium-c145aeb2bf13ac408fc3e8233acca43d4251bbdc.tar.xz
openjpeg: Prevent bad cast in opj_j2k_update_image_data
R=tsepez@chromium.org BUG=587227 Review URL: https://codereview.chromium.org/1726843002 .
Diffstat (limited to 'third_party/libopenjpeg20/j2k.c')
-rw-r--r--third_party/libopenjpeg20/j2k.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/third_party/libopenjpeg20/j2k.c b/third_party/libopenjpeg20/j2k.c
index b20f219bf1..9056feb29a 100644
--- a/third_party/libopenjpeg20/j2k.c
+++ b/third_party/libopenjpeg20/j2k.c
@@ -8211,6 +8211,12 @@ static OPJ_BOOL opj_j2k_update_image_data (opj_tcd_t * p_tcd, OPJ_BYTE * p_data,
* */
assert( l_res->x0 >= 0);
assert( l_res->x1 >= 0);
+
+ /* Prevent bad casting to unsigned values in the subsequent lines. */
+ if ( l_res->x0 < 0 || l_res->x1 < 0 || l_res->y0 < 0 || l_res->y1 < 0 ) {
+ return OPJ_FALSE;
+ }
+
if ( l_x0_dest < (OPJ_UINT32)l_res->x0 ) {
l_start_x_dest = (OPJ_UINT32)l_res->x0 - l_x0_dest;
l_offset_x0_src = 0;