From 7918cc0463558015823bdf8c76c9a02ed56660cb Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Tue, 13 Oct 2020 13:45:40 +0900 Subject: [PATCH] tvgSvgLoader: Add points copy of missing polygon/polyline When using node, do atrribute copy. At that time, when target(url) is polygon or polyline, points array is not copied, causing a problem in output. So, add missing array copy. Change-Id: I0c8b295f4723a3e4d96831191073d49058d2923a --- src/loaders/svg/tvgSvgLoader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index 8e52b44..cd1fec7 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -1546,12 +1546,14 @@ static void _copyAttr(SvgNode* to, SvgNode* from) } case SvgNodeType::Polygon: { to->node.polygon.pointsCount = from->node.polygon.pointsCount; - to->node.polygon.points = (float*)calloc(to->node.polygon.pointsCount, sizeof(float)); + 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*)calloc(to->node.polyline.pointsCount, sizeof(float)); + 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; } default: { -- 2.7.4