Kaydet (Commit) 133cc249 authored tarafından Caolán McNamara's avatar Caolán McNamara

ofz#4072 Integer-overflow

Change-Id: Ib94d4021be86e93e6ed0e836fbab0d8d0ca6f738
Reviewed-on: https://gerrit.libreoffice.org/44346Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 95d35187
...@@ -441,13 +441,17 @@ sal_Int32 TableLayouter::distribute( LayoutVector& rLayouts, sal_Int32 nDistribu ...@@ -441,13 +441,17 @@ sal_Int32 TableLayouter::distribute( LayoutVector& rLayouts, sal_Int32 nDistribu
do do
{ {
bConstrainsBroken = false;
// first enforce minimum size constrains on all entities // first enforce minimum size constrains on all entities
for( nIndex = 0; nIndex < nCount; ++nIndex ) for( nIndex = 0; nIndex < nCount; ++nIndex )
{ {
Layout& rLayout = rLayouts[nIndex]; Layout& rLayout = rLayouts[nIndex];
if( rLayout.mnSize < rLayout.mnMinSize ) if( rLayout.mnSize < rLayout.mnMinSize )
{ {
nDistribute -= rLayout.mnMinSize - rLayout.mnSize; sal_Int32 nDiff(0);
bConstrainsBroken |= o3tl::checked_sub(rLayout.mnMinSize, rLayout.mnSize, nDiff);
nDistribute -= nDiff;
rLayout.mnSize = rLayout.mnMinSize; rLayout.mnSize = rLayout.mnMinSize;
} }
} }
...@@ -463,8 +467,6 @@ sal_Int32 TableLayouter::distribute( LayoutVector& rLayouts, sal_Int32 nDistribu ...@@ -463,8 +467,6 @@ sal_Int32 TableLayouter::distribute( LayoutVector& rLayouts, sal_Int32 nDistribu
nCurrentWidth = o3tl::saturating_add(nCurrentWidth, rLayout.mnSize); nCurrentWidth = o3tl::saturating_add(nCurrentWidth, rLayout.mnSize);
} }
bConstrainsBroken = false;
// now distribute over entities // now distribute over entities
if( (nCurrentWidth != 0) && (nDistribute != 0) ) if( (nCurrentWidth != 0) && (nDistribute != 0) )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment