tools/inc/poly.h | 2 +- tools/source/generic/poly.cxx | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-)
New commits: commit 28e1680182666c13599b744efca8e0ebd08706d5 Author: Caolán McNamara <caol...@redhat.com> Date: Mon Jan 2 11:53:31 2017 +0000 ofz#372 check if ImplSplit succeeded (cherry picked from commit 62a97e6a561ce65e88d4c537a1b82c336f012722) (cherry picked from commit 6431e2bff67e81b4aff4e3b52e67903e1cd566f3) Change-Id: I1e34295fe3ee5f77e787f583616d52fa92a0eca4 Reviewed-on: https://gerrit.libreoffice.org/32640 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrh...@googlemail.com> diff --git a/tools/inc/poly.h b/tools/inc/poly.h index f15f01f..3269efe 100644 --- a/tools/inc/poly.h +++ b/tools/inc/poly.h @@ -42,7 +42,7 @@ public: void ImplSetSize( sal_uInt16 nSize, bool bResize = true ); void ImplCreateFlagArray(); - void ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pInitPoly = NULL ); + bool ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pInitPoly = NULL ); }; #define MAX_POLYGONS ((sal_uInt16)0x3FF0) diff --git a/tools/source/generic/poly.cxx b/tools/source/generic/poly.cxx index 519c9b4..266ac2d 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -212,11 +212,14 @@ void ImplPolygon::ImplSetSize( sal_uInt16 nNewSize, bool bResize ) mnPoints = nNewSize; } -void ImplPolygon::ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pInitPoly ) +bool ImplPolygon::ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pInitPoly ) { //Can't fit this in :-(, throw ? if (mnPoints + nSpace > USHRT_MAX) - return; + { + SAL_WARN("tools", "Polygon needs " << mnPoints + nSpace << " points, but only " << USHRT_MAX << " possible"); + return false; + } const sal_uInt16 nNewSize = mnPoints + nSpace; const std::size_t nSpaceSize = static_cast<std::size_t>(nSpace) * sizeof(Point); @@ -272,6 +275,8 @@ void ImplPolygon::ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pI mpPointAry = pNewAry; mnPoints = nNewSize; } + + return true; } void ImplPolygon::ImplCreateFlagArray() @@ -1473,8 +1478,8 @@ void Polygon::Insert( sal_uInt16 nPos, const Point& rPt ) if( nPos >= mpImplPolygon->mnPoints ) nPos = mpImplPolygon->mnPoints; - mpImplPolygon->ImplSplit( nPos, 1 ); - mpImplPolygon->mpPointAry[ nPos ] = rPt; + if (mpImplPolygon->ImplSplit(nPos, 1)) + mpImplPolygon->mpPointAry[ nPos ] = rPt; } void Polygon::Insert( sal_uInt16 nPos, const tools::Polygon& rPoly )
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits