mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 14:41:50 +00:00
svg_loader: prevent heap memory overflow.
if the input points are odd-numberd by invalid svg data, it could access invalid memory. Prevents it just in case.
This commit is contained in:
parent
5da4c81138
commit
86fd0f67cf
1 changed files with 2 additions and 2 deletions
|
@ -291,7 +291,7 @@ static bool _appendShape(SvgNode* node, Shape* shape, float vx, float vy, float
|
|||
case SvgNodeType::Polygon: {
|
||||
if (node->node.polygon.pointsCount < 2) break;
|
||||
shape->moveTo(node->node.polygon.points[0], node->node.polygon.points[1]);
|
||||
for (int i = 2; i < node->node.polygon.pointsCount; i += 2) {
|
||||
for (int i = 2; i < node->node.polygon.pointsCount - 1; i += 2) {
|
||||
shape->lineTo(node->node.polygon.points[i], node->node.polygon.points[i + 1]);
|
||||
}
|
||||
shape->close();
|
||||
|
@ -300,7 +300,7 @@ static bool _appendShape(SvgNode* node, Shape* shape, float vx, float vy, float
|
|||
case SvgNodeType::Polyline: {
|
||||
if (node->node.polygon.pointsCount < 2) break;
|
||||
shape->moveTo(node->node.polygon.points[0], node->node.polygon.points[1]);
|
||||
for (int i = 2; i < node->node.polygon.pointsCount; i += 2) {
|
||||
for (int i = 2; i < node->node.polygon.pointsCount - 1; i += 2) {
|
||||
shape->lineTo(node->node.polygon.points[i], node->node.polygon.points[i + 1]);
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue