disallow negative setReserve() calls
We already assert that setCount()'s argument is non-negative. This does the same for setReserve(). There was one call site I could find that was actually sometimes passing negative values to setReserve(), guarded here. Already reviewed: https://skia-review.googlesource.com/c/skia/+/115982 Change-Id: Ia52a286732bf4056e9baf09555d27bab9abf2554 Reviewed-on: https://skia-review.googlesource.com/122305 Reviewed-by: Mike Klein <mtklein@chromium.org> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
parent
bd000a11c7
commit
23e4544e94
@ -143,6 +143,7 @@ public:
|
||||
}
|
||||
|
||||
void setReserve(int reserve) {
|
||||
SkASSERT(reserve >= 0);
|
||||
if (reserve > fReserve) {
|
||||
this->resizeStorageToAtLeast(reserve);
|
||||
}
|
||||
|
@ -347,7 +347,9 @@ bool SkInsetConvexPolygon(const SkPoint* inputPolygonVerts, int inputPolygonSize
|
||||
static constexpr SkScalar kCleanupTolerance = 0.01f;
|
||||
|
||||
insetPolygon->reset();
|
||||
insetPolygon->setReserve(insetVertexCount);
|
||||
if (insetVertexCount >= 0) {
|
||||
insetPolygon->setReserve(insetVertexCount);
|
||||
}
|
||||
currIndex = -1;
|
||||
for (int i = 0; i < inputPolygonSize; ++i) {
|
||||
if (edgeData[i].fValid && (currIndex == -1 ||
|
||||
|
Loading…
Reference in New Issue
Block a user