summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-05-27 23:39:50 +0200
committerThorsten Behrens <Thorsten.Behrens@CIB.de>2018-05-27 23:39:50 +0200
commit4a666eae740a888e9fecf5dd6ec370fb044bc377 (patch)
tree3d3a32ff1042056d8530bd1096ceed8acfffd5d6
parentf53358310a4e69e38f6c2c805cdc3887afbb3749 (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> Change-Id: I1e34295fe3ee5f77e787f583616d52fa92a0eca4
-rw-r--r--tools/inc/poly.h2
-rw-r--r--tools/source/generic/poly.cxx13
2 files changed, 10 insertions, 5 deletions
diff --git a/tools/inc/poly.h b/tools/inc/poly.h
index 93f1096dfc95..8e59aa11aa6d 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 1caec3787062..9a1474125fb9 100644
--- a/tools/source/generic/poly.cxx
+++ b/tools/source/generic/poly.cxx
@@ -207,13 +207,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;
@@ -268,6 +271,8 @@ void ImplPolygon::ImplSplit( sal_uInt16 nPos, sal_uInt16 nSpace, ImplPolygon* pI
mpPointAry = pNewAry;
mnPoints = nNewSize;
}
+
+ return true;
}
void ImplPolygon::ImplCreateFlagArray()
@@ -1467,8 +1472,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 )
{