mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-09 14:13:43 +00:00
loader/svg: Skip to invalid polygon
If a Polygon's points array is odd, it is not a valid shape.
This commit is contained in:
parent
d98cb1a84b
commit
75e587a9a9
2 changed files with 6 additions and 1 deletions
|
@ -1726,6 +1726,10 @@ static bool _attrParsePolygonPoints(const char* str, SvgPolygonNode* polygon)
|
||||||
{
|
{
|
||||||
float num;
|
float num;
|
||||||
while (_parseNumber(&str, nullptr, &num)) polygon->pts.push(num);
|
while (_parseNumber(&str, nullptr, &num)) polygon->pts.push(num);
|
||||||
|
if (polygon->pts.count % 2 != 0) {
|
||||||
|
polygon->pts.clear();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1768,7 +1772,7 @@ static SvgNode* _createPolygonNode(SvgLoaderData* loader, SvgNode* parent, const
|
||||||
|
|
||||||
if (!loader->svgParse->node) return nullptr;
|
if (!loader->svgParse->node) return nullptr;
|
||||||
|
|
||||||
func(buf, bufLength, _attrParsePolygonNode, loader);
|
if (!func(buf, bufLength, _attrParsePolygonNode, loader)) return nullptr;
|
||||||
return loader->svgParse->node;
|
return loader->svgParse->node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -358,6 +358,7 @@ bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttr
|
||||||
if (!func((void*)data, tmpBuf, tval)) {
|
if (!func((void*)data, tmpBuf, tval)) {
|
||||||
if (!_isIgnoreUnsupportedLogAttributes(tmpBuf, tval)) {
|
if (!_isIgnoreUnsupportedLogAttributes(tmpBuf, tval)) {
|
||||||
TVGLOG("SVG", "Unsupported attributes used [Elements type: %s][Id : %s][Attribute: %s][Value: %s]", simpleXmlNodeTypeToString(((SvgLoaderData*)data)->svgParse->node->type), ((SvgLoaderData*)data)->svgParse->node->id ? ((SvgLoaderData*)data)->svgParse->node->id : "NO_ID", tmpBuf, tval ? tval : "NONE");
|
TVGLOG("SVG", "Unsupported attributes used [Elements type: %s][Id : %s][Attribute: %s][Value: %s]", simpleXmlNodeTypeToString(((SvgLoaderData*)data)->svgParse->node->type), ((SvgLoaderData*)data)->svgParse->node->id ? ((SvgLoaderData*)data)->svgParse->node->id : "NO_ID", tmpBuf, tval ? tval : "NONE");
|
||||||
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue