mirror of
https://github.com/thorvg/thorvg.git
synced 2025-07-25 07:39:02 +00:00
svg_loader: negative attrs length fix
After finding no attributes but white spaces, attrs length could be negative that resulted in segmentation fault in simpleXmlParseAttributes function. @Issue: #487
This commit is contained in:
parent
78bb8d1f2e
commit
520d6e7bbd
1 changed files with 2 additions and 2 deletions
|
@ -2174,11 +2174,11 @@ static void _svgLoaderParserXmlOpen(SvgLoaderData* loader, const char* content,
|
|||
if (attrs) {
|
||||
//Find out the tag name starting from content till sz length
|
||||
sz = attrs - content;
|
||||
attrsLength = length - sz;
|
||||
while ((sz > 0) && (isspace(content[sz - 1]))) sz--;
|
||||
if ((unsigned)sz >= sizeof(tagName)) return;
|
||||
strncpy(tagName, content, sz);
|
||||
tagName[sz] = '\0';
|
||||
attrsLength = length - sz;
|
||||
}
|
||||
|
||||
if ((method = _findGroupFactory(tagName))) {
|
||||
|
@ -2540,11 +2540,11 @@ static bool _svgLoaderParserForValidCheckXmlOpen(SvgLoaderData* loader, const ch
|
|||
|
||||
if (attrs) {
|
||||
sz = attrs - content;
|
||||
attrsLength = length - sz;
|
||||
while ((sz > 0) && (isspace(content[sz - 1]))) sz--;
|
||||
if ((unsigned)sz >= sizeof(tagName)) return false;
|
||||
strncpy(tagName, content, sz);
|
||||
tagName[sz] = '\0';
|
||||
attrsLength = length - sz;
|
||||
}
|
||||
|
||||
if ((method = _findGroupFactory(tagName))) {
|
||||
|
|
Loading…
Add table
Reference in a new issue