mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-13 19:44:28 +00:00
svg_loader: mem properly freed
delete -> free
This commit is contained in:
parent
f3450e1760
commit
ed640630c1
1 changed files with 13 additions and 13 deletions
|
@ -904,7 +904,7 @@ static void _handleClipPathAttr(TVG_UNUSED SvgLoaderData* loader, SvgNode* node,
|
|||
SvgStyleProperty* style = node->style;
|
||||
int len = strlen(value);
|
||||
if (len >= 3 && !strncmp(value, "url", 3)) {
|
||||
if (style->clipPath.url) delete(style->clipPath.url);
|
||||
if (style->clipPath.url) free(style->clipPath.url);
|
||||
style->clipPath.url = _idFromUrl((const char*)(value + 3));
|
||||
}
|
||||
}
|
||||
|
@ -915,7 +915,7 @@ static void _handleMaskAttr(TVG_UNUSED SvgLoaderData* loader, SvgNode* node, con
|
|||
SvgStyleProperty* style = node->style;
|
||||
int len = strlen(value);
|
||||
if (len >= 3 && !strncmp(value, "url", 3)) {
|
||||
if (style->mask.url) delete(style->mask.url);
|
||||
if (style->mask.url) free(style->mask.url);
|
||||
style->mask.url = _idFromUrl((const char*)(value + 3));
|
||||
}
|
||||
}
|
||||
|
@ -1009,7 +1009,7 @@ static bool _attrParseGNode(void* data, const char* key, const char* value)
|
|||
} else if (!strcmp(key, "transform")) {
|
||||
node->transform = _parseTransformationMatrix(value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) delete node->id;
|
||||
if (node->id && value) free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "clip-path")) {
|
||||
_handleClipPathAttr(loader, node, value);
|
||||
|
@ -1036,7 +1036,7 @@ static bool _attrParseClipPathNode(void* data, const char* key, const char* valu
|
|||
} else if (!strcmp(key, "transform")) {
|
||||
node->transform = _parseTransformationMatrix(value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) delete node->id;
|
||||
if (node->id && value) free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "clipPathUnits")) {
|
||||
if (!strcmp(value, "objectBoundingBox")) comp->userSpace = false;
|
||||
|
@ -1058,7 +1058,7 @@ static bool _attrParseMaskNode(void* data, const char* key, const char* value)
|
|||
} else if (!strcmp(key, "transform")) {
|
||||
node->transform = _parseTransformationMatrix(value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) delete node->id;
|
||||
if (node->id && value) free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "maskContentUnits")) {
|
||||
if (!strcmp(value, "objectBoundingBox")) comp->userSpace = false;
|
||||
|
@ -1208,7 +1208,7 @@ static bool _attrParsePathNode(void* data, const char* key, const char* value)
|
|||
} else if (!strcmp(key, "mask")) {
|
||||
_handleMaskAttr(loader, node, value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) delete node->id;
|
||||
if (node->id && value) free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else {
|
||||
return _parseStyleAttr(loader, key, value, false);
|
||||
|
@ -1268,7 +1268,7 @@ static bool _attrParseCircleNode(void* data, const char* key, const char* value)
|
|||
} else if (!strcmp(key, "mask")) {
|
||||
_handleMaskAttr(loader, node, value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) delete node->id;
|
||||
if (node->id && value) free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else {
|
||||
return _parseStyleAttr(loader, key, value, false);
|
||||
|
@ -1322,7 +1322,7 @@ static bool _attrParseEllipseNode(void* data, const char* key, const char* value
|
|||
}
|
||||
|
||||
if (!strcmp(key, "id")) {
|
||||
if (node->id && value) delete node->id;
|
||||
if (node->id && value) free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "style")) {
|
||||
return simpleXmlParseW3CAttribute(value, _parseStyleAttr, loader);
|
||||
|
@ -1405,7 +1405,7 @@ static bool _attrParsePolygonNode(void* data, const char* key, const char* value
|
|||
} else if (!strcmp(key, "mask")) {
|
||||
_handleMaskAttr(loader, node, value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) delete node->id;
|
||||
if (node->id && value) free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else {
|
||||
return _parseStyleAttr(loader, key, value, false);
|
||||
|
@ -1479,7 +1479,7 @@ static bool _attrParseRectNode(void* data, const char* key, const char* value)
|
|||
}
|
||||
|
||||
if (!strcmp(key, "id")) {
|
||||
if (node->id && value) delete node->id;
|
||||
if (node->id && value) free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "style")) {
|
||||
ret = simpleXmlParseW3CAttribute(value, _parseStyleAttr, loader);
|
||||
|
@ -1542,7 +1542,7 @@ static bool _attrParseLineNode(void* data, const char* key, const char* value)
|
|||
}
|
||||
|
||||
if (!strcmp(key, "id")) {
|
||||
if (node->id && value) delete node->id;
|
||||
if (node->id && value) free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "style")) {
|
||||
return simpleXmlParseW3CAttribute(value, _parseStyleAttr, loader);
|
||||
|
@ -1612,7 +1612,7 @@ static bool _attrParseImageNode(void* data, const char* key, const char* value)
|
|||
if (!strcmp(key, "href") || !strcmp(key, "xlink:href")) {
|
||||
image->href = _idFromHref(value);
|
||||
} else if (!strcmp(key, "id")) {
|
||||
if (node->id && value) delete node->id;
|
||||
if (node->id && value) free(node->id);
|
||||
node->id = _copyId(value);
|
||||
} else if (!strcmp(key, "style")) {
|
||||
return simpleXmlParseW3CAttribute(value, _parseStyleAttr, loader);
|
||||
|
@ -1873,7 +1873,7 @@ static bool _attrParseUseNode(void* data, const char* key, const char* value)
|
|||
nodeFrom = _findChildById(defs, id);
|
||||
if (nodeFrom) {
|
||||
_cloneNode(nodeFrom, node);
|
||||
delete id;
|
||||
free(id);
|
||||
} else {
|
||||
//some svg export software include <defs> element at the end of the file
|
||||
//if so the 'from' element won't be found now and we have to repeat finding
|
||||
|
|
Loading…
Add table
Reference in a new issue