summaryrefslogtreecommitdiff
path: root/include/basebmp
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2014-08-25 11:31:30 +0100
committerCaolán McNamara <caolanm@redhat.com>2014-08-25 21:06:21 +0100
commit6182437f8312e5823b3c9022993730428e572667 (patch)
tree6362a8d19c988bc4f3a93f83ce9a7a76abdd3ffb /include/basebmp
parent739adde53bf93afa1d1cd2ea2ecaf0754feec934 (diff)
return false if the clip region would div by zero
Change-Id: Ia0928306b3608df9c48a19b517edac54ba43bd57
Diffstat (limited to 'include/basebmp')
-rw-r--r--include/basebmp/clippedlinerenderer.hxx18
1 files changed, 14 insertions, 4 deletions
diff --git a/include/basebmp/clippedlinerenderer.hxx b/include/basebmp/clippedlinerenderer.hxx
index 077ff48255ab..b3a5fd098f95 100644
--- a/include/basebmp/clippedlinerenderer.hxx
+++ b/include/basebmp/clippedlinerenderer.hxx
@@ -89,7 +89,12 @@ inline bool prepareClip( sal_Int32 a1,
if( clipCode1 & (aMinFlag|aMaxFlag) )
{
- cb = (ca + da - int(!bRoundTowardsPt2)) / (2*da);
+ sal_Int32 da2 = 2*da;
+
+ if (da2 == 0)
+ return false; // overflow
+
+ cb = (ca + da - int(!bRoundTowardsPt2)) / (da2);
if( sb >= 0 )
{
@@ -104,11 +109,16 @@ inline bool prepareClip( sal_Int32 a1,
return false; // fully clipped
}
- io_rem += ca - 2*da*cb;
+ io_rem += ca - da2*cb;
}
else
{
- ca = (cb - da + 2*db - int(bRoundTowardsPt2)) / (2*db);
+ sal_Int32 db2 = 2*db;
+
+ if (db2 == 0)
+ return false; // overflow
+
+ ca = (cb - da + db2 - int(bRoundTowardsPt2)) / (db2);
if( sa >= 0 )
{
o_as = a1 + ca;
@@ -122,7 +132,7 @@ inline bool prepareClip( sal_Int32 a1,
return false; // fully clipped
}
- io_rem += 2*db*ca - cb;
+ io_rem += db2*ca - cb;
}
}
else