From 9d03bc27b81a2ec598d05a8d22194d0d318f9391 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 28 Jun 2021 13:38:12 +0900 Subject: [PATCH] svg_loader: fix trivial build warnings. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ../src/loaders/svg/tvgSvgLoader.cpp: In function ‘void _copyAttr(SvgNode*, const SvgNode*)’: ../src/loaders/svg/tvgSvgLoader.cpp:1598:60: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘struct SvgStyleProperty’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess] memcpy(to->style, from->style, sizeof(SvgStyleProperty)); @Issue: 498 --- src/loaders/svg/tvgSvgLoader.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/loaders/svg/tvgSvgLoader.cpp b/src/loaders/svg/tvgSvgLoader.cpp index f420d6d..f251554 100644 --- a/src/loaders/svg/tvgSvgLoader.cpp +++ b/src/loaders/svg/tvgSvgLoader.cpp @@ -1596,15 +1596,13 @@ static void _copyAttr(SvgNode* to, const SvgNode* from) { //Copy matrix attribute if (from->transform) { - to->transform = (Matrix*)calloc(1, sizeof(Matrix)); - if (to->transform) memcpy(to->transform, from->transform, sizeof(Matrix)); + to->transform = (Matrix*)malloc(sizeof(Matrix)); + if (to->transform) *to->transform = *from->transform; } - //Copy style attribute; - memcpy(to->style, from->style, sizeof(SvgStyleProperty)); + //Copy style attribute + *to->style = *from->style; if (from->style->fill.paint.url) to->style->fill.paint.url = new string(from->style->fill.paint.url->c_str()); if (from->style->stroke.paint.url) to->style->stroke.paint.url = new string(from->style->stroke.paint.url->c_str()); - - //Copy style composite attribute (clip-path, mask, ...) if (from->style->comp.url) to->style->comp.url = new string(from->style->comp.url->c_str()); //Copy node attribute -- 2.7.4