svg_loader: preventing memory leak

A memory leak occured when the 'id' attribute was given multiple times
for a given gradient element. Fixed.
This commit is contained in:
Mira Grudzinska 2022-01-08 23:47:38 +01:00 committed by Hermet Park
parent eb75745a19
commit 1f6c236fa3

View file

@ -2098,6 +2098,7 @@ static bool _attrParseRadialGradientNode(void* data, const char* key, const char
} }
if (!strcmp(key, "id")) { if (!strcmp(key, "id")) {
if (grad->id && value) free(grad->id);
grad->id = _copyId(value); grad->id = _copyId(value);
} else if (!strcmp(key, "spreadMethod")) { } else if (!strcmp(key, "spreadMethod")) {
grad->spread = _parseSpreadValue(value); grad->spread = _parseSpreadValue(value);
@ -2286,6 +2287,7 @@ static bool _attrParseLinearGradientNode(void* data, const char* key, const char
} }
if (!strcmp(key, "id")) { if (!strcmp(key, "id")) {
if (grad->id && value) free(grad->id);
grad->id = _copyId(value); grad->id = _copyId(value);
} else if (!strcmp(key, "spreadMethod")) { } else if (!strcmp(key, "spreadMethod")) {
grad->spread = _parseSpreadValue(value); grad->spread = _parseSpreadValue(value);