From c8649af8d0353e2fba2e472f0ace50f5bd8167b2 Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Tue, 20 Sep 2022 11:16:17 +0300 Subject: Assert that cow_wrapped objects aren't called to do nothing An omission from commit e39fa3c4f5ae2560a4b6f6f789a0c5098ac43cf4 Simplify b2d(poly)polygon implementation Change-Id: Ib0b10e06baf91888f0e9797e670e0626f512af15 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140229 Tested-by: Mike Kaganski Reviewed-by: Mike Kaganski --- basegfx/source/polygon/b2dpolygon.cxx | 9 +++++++++ basegfx/source/polygon/b2dpolypolygon.cxx | 2 ++ 2 files changed, 11 insertions(+) (limited to 'basegfx') diff --git a/basegfx/source/polygon/b2dpolygon.cxx b/basegfx/source/polygon/b2dpolygon.cxx index 03957c8710a3..b0171ef000e2 100644 --- a/basegfx/source/polygon/b2dpolygon.cxx +++ b/basegfx/source/polygon/b2dpolygon.cxx @@ -82,6 +82,7 @@ public: void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rValue, sal_uInt32 nCount) { + assert(nCount > 0); assert(nIndex <= maVector.size()); // add nCount copies of rValue maVector.insert(maVector.begin() + nIndex, nCount, rValue); @@ -89,6 +90,7 @@ public: void insert(sal_uInt32 nIndex, const CoordinateDataArray2D& rSource) { + assert(rSource.maVector.size() > 0); assert(nIndex <= maVector.size()); // insert data auto aIndex = maVector.begin(); @@ -100,6 +102,7 @@ public: void remove(sal_uInt32 nIndex, sal_uInt32 nCount) { + assert(nCount > 0); assert(nIndex + nCount <= maVector.size()); // remove point data const auto aStart = maVector.begin() + nIndex; @@ -328,6 +331,7 @@ public: void insert(sal_uInt32 nIndex, const ControlVectorPair2D& rValue, sal_uInt32 nCount) { + assert(nCount > 0); assert(nIndex <= maVector.size()); // add nCount copies of rValue @@ -342,6 +346,7 @@ public: void insert(sal_uInt32 nIndex, const ControlVectorArray2D& rSource) { + assert(rSource.maVector.size() > 0); assert(nIndex <= maVector.size()); // insert data @@ -362,6 +367,7 @@ public: void remove(sal_uInt32 nIndex, sal_uInt32 nCount) { + assert(nCount > 0); assert(nIndex + nCount <= maVector.size()); const ControlVectorPair2DVector::iterator aDeleteStart(maVector.begin() + nIndex); @@ -689,6 +695,7 @@ public: void insert(sal_uInt32 nIndex, const basegfx::B2DPoint& rPoint, sal_uInt32 nCount) { + assert(nCount > 0); mpBufferedData.reset(); auto aCoordinate = rPoint; maPoints.insert(nIndex, aCoordinate, nCount); @@ -804,6 +811,7 @@ public: void append(const ImplB2DPolygon& rSource) { + assert(rSource.maPoints.count() > 0); const sal_uInt32 nIndex = count(); mpBufferedData.reset(); @@ -828,6 +836,7 @@ public: void remove(sal_uInt32 nIndex, sal_uInt32 nCount) { + assert(nCount > 0); mpBufferedData.reset(); maPoints.remove(nIndex, nCount); diff --git a/basegfx/source/polygon/b2dpolypolygon.cxx b/basegfx/source/polygon/b2dpolypolygon.cxx index dc8f0f53e98c..6ce3b398a1fb 100644 --- a/basegfx/source/polygon/b2dpolypolygon.cxx +++ b/basegfx/source/polygon/b2dpolypolygon.cxx @@ -102,6 +102,7 @@ public: void insert(sal_uInt32 nIndex, const basegfx::B2DPolygon& rPolygon, sal_uInt32 nCount) { + assert(nCount > 0); assert(nIndex <= maPolygons.size()); // add nCount copies of rPolygon maPolygons.insert(maPolygons.begin() + nIndex, nCount, rPolygon); @@ -131,6 +132,7 @@ public: void remove(sal_uInt32 nIndex, sal_uInt32 nCount) { + assert(nCount > 0); assert(nIndex + nCount <= maPolygons.size()); // remove polygon data auto aStart(maPolygons.begin() + nIndex); -- cgit v1.2.3