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:
Mira Grudzinska 2022-01-17 00:14:29 +01:00 committed by Hermet Park
parent 04d3bb0ec0
commit ed3b17b228

View file

@ -1904,15 +1904,17 @@ static void _copyAttr(SvgNode* to, const SvgNode* from)
break;
}
case SvgNodeType::Polygon: {
to->node.polygon.pointsCount = from->node.polygon.pointsCount;
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;
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: {