diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-02-25 16:44:19 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-02-26 09:30:17 +0100 |
commit | 60c121981d829ef322718a69900a1585e87efb84 (patch) | |
tree | 09a4e5b957bf6955086f8c83b4c82629cfd7dba5 /sw/source/core/text/itradj.cxx | |
parent | 8e9a2c860eadfd429a24a0cb98bf5c2aa4a60e61 (diff) |
SwGluePortion::GetPrtGlue() can legitimately be larger than 'short`
At least during JunitTest_sw_unoapi_4
sw.SwXTextTable::com::sun::star::text::TextTable::TableColumnSeparators, some
SwFormatFrameSize is created with a width of USHRT_MAX ("Set USHRT_MAX as the
Table's default SSize") in SwDoc::InsertTable
(sw/source/core/docnode/ndtbl.cxx). In SwTabFrame::Format
(sw/source/core/layout/tabfrm.cxx) that leads to nWishedTableWidth with a value
near USHRT_MAX and substantially larger than nMax, causing nLeftSpacing to be a
large negative value in the text::HoriOrientation::CENTER case. That in turn
causes SwTextAdjuster::CalcRightMargin (sw/source/core/text/itradj.cxx) to
set
pRight->PrtWidth( sal_uInt16( nRealWidth - nPrtWidth ) );
with a value of 32768 (where pRight is a SwGluePortion). And a later call to
that SwGluePortion's GetPrtGlue would try to convert that 32768 to 'short',
getting flagged by Clang's -fsanitize=implicit-signed-integer-truncation.
In addition to changing GetPrtGlue (and MoveGlue) to use 'long' instead of
'short', drop some unncessary narrowing casts from client code.
Change-Id: I6a0d763acfad1fc3b550ec6107adf9f5429dd005
Reviewed-on: https://gerrit.libreoffice.org/68253
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'sw/source/core/text/itradj.cxx')
-rw-r--r-- | sw/source/core/text/itradj.cxx | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sw/source/core/text/itradj.cxx b/sw/source/core/text/itradj.cxx index 14517379fc9a..047e26b6220e 100644 --- a/sw/source/core/text/itradj.cxx +++ b/sw/source/core/text/itradj.cxx @@ -435,7 +435,7 @@ SwTwips SwTextAdjuster::CalcKanaAdj( SwLineLayout* pCurrent ) if ( nKanaIdx == pCurrent->GetKanaComp().size() ) pCurrent->GetKanaComp().push_back( nNull ); - sal_uInt16 nRest; + long nRest; if ( pPos->InTabGrp() ) { @@ -759,9 +759,9 @@ void SwTextAdjuster::CalcDropAdjust() if( pRight && pRight != pLeft ) { // 5) Calculate nMinLeft. Who is the most to left? - const sal_uInt16 nDropLineStart = - sal_uInt16(GetLineStart()) + pLeft->Width() + pDropPor->Width(); - sal_uInt16 nMinLeft = nDropLineStart; + const auto nDropLineStart = + GetLineStart() + pLeft->Width() + pDropPor->Width(); + auto nMinLeft = nDropLineStart; for( sal_uInt16 i = 1; i < GetDropLines(); ++i ) { if( NextLine() ) @@ -776,8 +776,8 @@ void SwTextAdjuster::CalcDropAdjust() nMinLeft = 0; else { - const sal_uInt16 nLineStart = - sal_uInt16(GetLineStart()) + pMar->Width(); + const auto nLineStart = + GetLineStart() + pMar->Width(); if( nMinLeft > nLineStart ) nMinLeft = nLineStart; } @@ -789,7 +789,7 @@ void SwTextAdjuster::CalcDropAdjust() { // The Glue is always passed from pLeft to pRight, so that // the text moves to the left. - const short nGlue = nDropLineStart - nMinLeft; + const auto nGlue = nDropLineStart - nMinLeft; if( !nMinLeft ) pLeft->MoveAllGlue( pRight ); else |