mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 14:41:50 +00:00
common shape: handling dash patterns < 1
For the dash pattern values (both, length and gap) < 1 the program crashed. curLen - variable type changed from int to float.
This commit is contained in:
parent
0b767750e6
commit
4b58c5a5de
3 changed files with 6 additions and 3 deletions
|
@ -165,7 +165,7 @@ struct SwStroke
|
||||||
struct SwDashStroke
|
struct SwDashStroke
|
||||||
{
|
{
|
||||||
SwOutline* outline;
|
SwOutline* outline;
|
||||||
int32_t curLen;
|
float curLen;
|
||||||
int32_t curIdx;
|
int32_t curIdx;
|
||||||
Point ptStart;
|
Point ptStart;
|
||||||
Point ptCur;
|
Point ptCur;
|
||||||
|
|
|
@ -113,7 +113,6 @@ static void _outlineMoveTo(SwOutline& outline, const Point* to, const Matrix* tr
|
||||||
_growOutlinePoint(outline, 1);
|
_growOutlinePoint(outline, 1);
|
||||||
|
|
||||||
outline.pts[outline.ptsCnt] = _transform(to, transform);
|
outline.pts[outline.ptsCnt] = _transform(to, transform);
|
||||||
|
|
||||||
outline.types[outline.ptsCnt] = SW_CURVE_TYPE_POINT;
|
outline.types[outline.ptsCnt] = SW_CURVE_TYPE_POINT;
|
||||||
|
|
||||||
if (outline.ptsCnt > 0) {
|
if (outline.ptsCnt > 0) {
|
||||||
|
|
|
@ -339,6 +339,9 @@ Result Shape::stroke(const float* dashPattern, uint32_t cnt) noexcept
|
||||||
{
|
{
|
||||||
if (cnt < 2 || !dashPattern) return Result::InvalidArguments;
|
if (cnt < 2 || !dashPattern) return Result::InvalidArguments;
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < cnt; i++)
|
||||||
|
if (dashPattern[i] < FLT_EPSILON) return Result::InvalidArguments;
|
||||||
|
|
||||||
if (!pImpl->strokeDash(dashPattern, cnt)) return Result::FailedAllocation;
|
if (!pImpl->strokeDash(dashPattern, cnt)) return Result::FailedAllocation;
|
||||||
|
|
||||||
return Result::Success;
|
return Result::Success;
|
||||||
|
@ -350,6 +353,7 @@ uint32_t Shape::strokeDash(const float** dashPattern) const noexcept
|
||||||
if (!pImpl->stroke) return 0;
|
if (!pImpl->stroke) return 0;
|
||||||
|
|
||||||
if (dashPattern) *dashPattern = pImpl->stroke->dashPattern;
|
if (dashPattern) *dashPattern = pImpl->stroke->dashPattern;
|
||||||
|
|
||||||
return pImpl->stroke->dashCnt;
|
return pImpl->stroke->dashCnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue