tdf#165582: nMaxWidth may be negative

Change-Id: Ibe4a57e8a098b219e2662d3ce8645d5caef98123
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182536
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2025-03-05 16:58:06 +05:00
parent 50fe13355e
commit f6f1c7eb64

View File

@ -227,11 +227,12 @@ static void GetLimitedStringPart(const SwTextFormatInfo& rInf, TextFrameIndex nI
TextFrameIndex nLength, sal_uInt16 nComp, SwTwips nOriginalWidth,
SwTwips nMaxWidth, TextFrameIndex& rOutLength, SwTwips& rOutWidth)
{
assert(nMaxWidth >= 0);
assert(nLength >= TextFrameIndex(0));
const SwScriptInfo& rSI = rInf.GetParaPortion()->GetScriptInfo();
rOutLength = nLength;
rOutWidth = nOriginalWidth;
if (nMaxWidth < 0)
nMaxWidth = 0;
while (rOutWidth > nMaxWidth)
{
TextFrameIndex nNewOnLineLengthGuess(rOutLength.get() * nMaxWidth / rOutWidth);