summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2/JBig2_Image.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec/jbig2/JBig2_Image.cpp')
-rw-r--r--core/fxcodec/jbig2/JBig2_Image.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/core/fxcodec/jbig2/JBig2_Image.cpp b/core/fxcodec/jbig2/JBig2_Image.cpp
index 13323bac30..b0d75d4d96 100644
--- a/core/fxcodec/jbig2/JBig2_Image.cpp
+++ b/core/fxcodec/jbig2/JBig2_Image.cpp
@@ -259,14 +259,18 @@ bool CJBig2_Image::composeTo_opt2(CJBig2_Image* pDst,
int32_t xs0 = x < 0 ? -x : 0;
int32_t xs1;
- if (x + m_nWidth > pDst->m_nWidth)
- xs1 = pDst->m_nWidth - x;
+ FX_SAFE_INT32 iChecked = pDst->m_nWidth;
+ iChecked -= x;
+ if (iChecked.IsValid() && m_nWidth > iChecked.ValueOrDie())
+ xs1 = iChecked.ValueOrDie();
else
xs1 = m_nWidth;
int32_t ys0 = y < 0 ? -y : 0;
int32_t ys1;
- if (y + m_nHeight > pDst->m_nHeight)
+ iChecked = pDst->m_nHeight;
+ iChecked -= y;
+ if (iChecked.IsValid() && m_nHeight > iChecked.ValueOrDie())
ys1 = pDst->m_nHeight - y;
else
ys1 = m_nHeight;