mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
svg_loader: preventing memcpy from a nullptr
In a case when a polygon/polyline had no points, there is nothing to be copied.
This commit is contained in:
parent
04d3bb0ec0
commit
ed3b17b228
1 changed files with 8 additions and 6 deletions
|
@ -1904,15 +1904,17 @@ static void _copyAttr(SvgNode* to, const SvgNode* from)
|
|||
break;
|
||||
}
|
||||
case SvgNodeType::Polygon: {
|
||||
to->node.polygon.pointsCount = from->node.polygon.pointsCount;
|
||||
to->node.polygon.points = (float*)malloc(to->node.polygon.pointsCount * sizeof(float));
|
||||
memcpy(to->node.polygon.points, from->node.polygon.points, to->node.polygon.pointsCount * sizeof(float));
|
||||
if ((to->node.polygon.pointsCount = from->node.polygon.pointsCount)) {
|
||||
to->node.polygon.points = (float*)malloc(to->node.polygon.pointsCount * sizeof(float));
|
||||
memcpy(to->node.polygon.points, from->node.polygon.points, to->node.polygon.pointsCount * sizeof(float));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Polyline: {
|
||||
to->node.polyline.pointsCount = from->node.polyline.pointsCount;
|
||||
to->node.polyline.points = (float*)malloc(to->node.polyline.pointsCount * sizeof(float));
|
||||
memcpy(to->node.polyline.points, from->node.polyline.points, to->node.polyline.pointsCount * sizeof(float));
|
||||
if ((to->node.polyline.pointsCount = from->node.polyline.pointsCount)) {
|
||||
to->node.polyline.points = (float*)malloc(to->node.polyline.pointsCount * sizeof(float));
|
||||
memcpy(to->node.polyline.points, from->node.polyline.points, to->node.polyline.pointsCount * sizeof(float));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SvgNodeType::Image: {
|
||||
|
|
Loading…
Add table
Reference in a new issue