diff options
-rw-r--r-- | tools/source/generic/poly.cxx | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index f104a33263c8..e4153b9af6f9 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -1540,6 +1540,14 @@ SvStream& ReadPolygon( SvStream& rIStream, Polygon& rPoly ) // read all points and create array rIStream.ReadUInt16( nPoints ); + + const size_t nMaxRecordsPossible = rIStream.remainingSize() / (2 * sizeof(sal_Int32)); + if (nPoints > nMaxRecordsPossible) + { + SAL_WARN("tools", "Polygon claims " << nPoints << " records, but only " << nMaxRecordsPossible << " possible"); + nPoints = nMaxRecordsPossible; + } + if ( rPoly.mpImplPolygon->mnRefCount != 1 ) { if ( rPoly.mpImplPolygon->mnRefCount ) @@ -1551,12 +1559,6 @@ SvStream& ReadPolygon( SvStream& rIStream, Polygon& rPoly ) { // Determine whether we need to write through operators - const size_t nMaxRecordsPossible = rIStream.remainingSize() / (2 * sizeof(sal_Int32)); - if (nPoints > nMaxRecordsPossible) - { - SAL_WARN("tools", "Polygon claims " << nPoints << " records, but only " << nMaxRecordsPossible << " possible"); - nPoints = nMaxRecordsPossible; - } #if (SAL_TYPES_SIZEOFLONG) == 4 #ifdef OSL_BIGENDIAN if ( rIStream.GetEndian() == SvStreamEndian::BIG ) |