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:
JunsuChoi 2024-04-05 13:42:02 +09:00 committed by Hermet Park
parent d98cb1a84b
commit 75e587a9a9
2 changed files with 6 additions and 1 deletions

View file

@ -1726,6 +1726,10 @@ static bool _attrParsePolygonPoints(const char* str, SvgPolygonNode* polygon)
{
float num;
while (_parseNumber(&str, nullptr, &num)) polygon->pts.push(num);
if (polygon->pts.count % 2 != 0) {
polygon->pts.clear();
return false;
}
return true;
}
@ -1768,7 +1772,7 @@ static SvgNode* _createPolygonNode(SvgLoaderData* loader, SvgNode* parent, const
if (!loader->svgParse->node) return nullptr;
func(buf, bufLength, _attrParsePolygonNode, loader);
if (!func(buf, bufLength, _attrParsePolygonNode, loader)) return nullptr;
return loader->svgParse->node;
}

View file

@ -358,6 +358,7 @@ bool simpleXmlParseAttributes(const char* buf, unsigned bufLength, simpleXMLAttr
if (!func((void*)data, 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");
goto error;
}
}
}