diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-01-02 11:53:31 +0000 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-04-23 17:46:43 +0200 |
commit | 0706f7efb7e18cbaa12db711530249186f8dd50f (patch) | |
tree | 3d564e50fb7f6f63100872959e2140483204d11b /tools | |
parent | f755b6efa6239cc6bd832e9fd6c74d9949a75fb8 (diff) |
ofz#372 check if ImplSplit succeeded
(cherry picked from commit 62a97e6a561ce65e88d4c537a1b82c336f012722)
(cherry picked from commit 6431e2bff67e81b4aff4e3b52e67903e1cd566f3)
Reviewed-on: https://gerrit.libreoffice.org/32640
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
(cherry picked from commit 28e1680182666c13599b744efca8e0ebd08706d5)
Change-Id: I1e34295fe3ee5f77e787f583616d52fa92a0eca4
(cherry picked from commit bbc97e7bafc3d1477c9bf6f7d1941e3b64c366e3)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/inc/poly.h | 2 | ||||
-rw-r--r-- | tools/source/generic/poly.cxx | 13 |
2 files changed, 10 insertions, 5 deletions
diff --git a/tools/inc/poly.h b/tools/inc/poly.h index d677bcd8b0ac..c614401f122c 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 457a05b4d112..8c378899be9d 100644 --- a/tools/source/generic/poly.cxx +++ b/tools/source/generic/poly.cxx @@ -208,13 +208,16 @@ 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 ) { const sal_uIntPtr nSpaceSize = nSpace * sizeof( Point ); //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; @@ -269,6 +272,8 @@ void ImplPolygon::ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pI mpPointAry = pNewAry; mnPoints = nNewSize; } + + return true; } void ImplPolygon::ImplCreateFlagArray() @@ -1444,8 +1449,8 @@ void Polygon::Insert( sal_uInt16 nPos, const Point& rPt, PolyFlags eFlags ) if( nPos >= mpImplPolygon->mnPoints ) nPos = mpImplPolygon->mnPoints; - mpImplPolygon->ImplSplit( nPos, 1 ); - mpImplPolygon->mpPointAry[ nPos ] = rPt; + if (mpImplPolygon->ImplSplit(nPos, 1)) + mpImplPolygon->mpPointAry[ nPos ] = rPt; if( POLY_NORMAL != eFlags ) { |