tdf#151283 calc hangs when try to open XLS file

regression from
    commit 258a8d133d
    Author: Noel Grandin <noel.grandin@collabora.co.uk>
    tdf#150034 very slow opening pathological chart

if nNewLen is < 10, we can get stuck in an infinite loop
because the calculation will not actually decrement nNewLen

Change-Id: I98920deaa087713c44531a7f6506d1d5d32b2e98
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140949
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2022-10-04 18:35:17 +02:00 committed by Noel Grandin
parent 0ab5a5ee6e
commit a36173359d

View file

@ -448,7 +448,7 @@ awt::Size lcl_placeLegendEntries(
DrawModelWrapper::removeShape(xEntry);
// The intention here is to make pathological cases with extremely large labels
// converge a little faster
if (std::abs(nRemainingSpace) > nSumHeight / 10)
if (nNewLen > 10 && std::abs(nRemainingSpace) > nSumHeight / 10)
nNewLen -= nNewLen / 10;
else
--nNewLen;