mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-08 13:43:43 +00:00
svg_loader: allow multiple <defs> tags without data and memory leak (#528)
* svg_loader: allow multiple defs without data and memory leak If the svg file contained multiple <defs> tags, each subsequent tag overwritten the previous tag. This resulted in incorrect rendering of the file and memory leaks. @Issues: 491 * svg_loader: allow multiple defs without data and memory leak- fix #1 Changed the idea to abandon node creating instead of deleting it after creation. Removed simpleXmlParseAttributes for _createDefsNode.
This commit is contained in:
parent
19a3190245
commit
3086f28b55
1 changed files with 2 additions and 2 deletions
|
@ -1068,9 +1068,8 @@ static SvgNode* _createNode(SvgNode* parent, SvgNodeType type)
|
|||
|
||||
static SvgNode* _createDefsNode(TVG_UNUSED SvgLoaderData* loader, TVG_UNUSED SvgNode* parent, const char* buf, unsigned bufLength)
|
||||
{
|
||||
if (loader->def && loader->doc->node.doc.defs) return nullptr;
|
||||
SvgNode* node = _createNode(nullptr, SvgNodeType::Defs);
|
||||
if (!node) return nullptr;
|
||||
simpleXmlParseAttributes(buf, bufLength, nullptr, node);
|
||||
return node;
|
||||
}
|
||||
|
||||
|
@ -2199,6 +2198,7 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
|
|||
node = method(loader, parent, attrs, attrsLength);
|
||||
}
|
||||
|
||||
if (!node) return;
|
||||
if (node->type == SvgNodeType::Defs) {
|
||||
loader->doc->node.doc.defs = node;
|
||||
loader->def = node;
|
||||
|
|
Loading…
Add table
Reference in a new issue