summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-10-25 17:16:29 +0100
committerCaolán McNamara <caolanm@redhat.com>2017-10-25 21:32:09 +0200
commit438e8b846f0f1d6fd2007c0871d26c005f254902 (patch)
treebe56f901cf8425d5cbe8a28a495d7416d4211e39 /svx
parent29d04ce9cd7fe886125e948a56dfdf573e934730 (diff)
ofz Integer-overflow
Change-Id: If78466f091c55279b21aaa936a4b77e665530aa5 Reviewed-on: https://gerrit.libreoffice.org/43849 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/table/tablelayouter.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/svx/source/table/tablelayouter.cxx b/svx/source/table/tablelayouter.cxx
index 2c38af69da0d..c6fbe4009b85 100644
--- a/svx/source/table/tablelayouter.cxx
+++ b/svx/source/table/tablelayouter.cxx
@@ -25,6 +25,7 @@
#include <cell.hxx>
#include "cellrange.hxx"
+#include <o3tl/safeint.hxx>
#include <tablemodel.hxx>
#include "tablerow.hxx"
#include "tablerows.hxx"
@@ -467,11 +468,12 @@ sal_Int32 TableLayouter::distribute( LayoutVector& rLayouts, sal_Int32 nDistribu
Layout& rLayout = rLayouts[nIndex];
if( (nDistribute > 0) || (rLayout.mnSize > rLayout.mnMinSize) )
{
- sal_Int32 n;
- if( nIndex == (nCount-1) )
- n = nDistributed; // for last entity use up rest
- else
- n = (nDistribute * rLayout.mnSize) / nCurrentWidth;
+ sal_Int32 n(nDistributed); // for last entity use up rest
+ if (nIndex != (nCount-1))
+ {
+ bConstrainsBroken |= o3tl::checked_multiply(nDistribute, rLayout.mnSize, n);
+ n /= nCurrentWidth;
+ }
nDistributed -= n;
rLayout.mnSize += n;