svg_loader: fixing segf when passing a nullptr to strcmp

This occurred when a gradient has no 'id' attribute.
This commit is contained in:
mgrudzinska 2022-04-03 22:32:26 +02:00 committed by Mira Grudzinska
parent 0925aa84a5
commit 470b885e65

View file

@ -2874,7 +2874,7 @@ static SvgStyleGradient* _gradientDup(Array<SvgStyleGradient*>* gradients, const
auto gradList = gradients->data; auto gradList = gradients->data;
for (uint32_t i = 0; i < gradients->count; ++i) { for (uint32_t i = 0; i < gradients->count; ++i) {
if (!strcmp((*gradList)->id, id)) { if ((*gradList)->id && !strcmp((*gradList)->id, id)) {
result = _cloneGradient(*gradList); result = _cloneGradient(*gradList);
break; break;
} }
@ -2884,7 +2884,7 @@ static SvgStyleGradient* _gradientDup(Array<SvgStyleGradient*>* gradients, const
if (result && result->ref) { if (result && result->ref) {
gradList = gradients->data; gradList = gradients->data;
for (uint32_t i = 0; i < gradients->count; ++i) { for (uint32_t i = 0; i < gradients->count; ++i) {
if (!strcmp((*gradList)->id, result->ref)) { if ((*gradList)->id && !strcmp((*gradList)->id, result->ref)) {
if (result->stops.count == 0) _cloneGradStops(result->stops, (*gradList)->stops); if (result->stops.count == 0) _cloneGradStops(result->stops, (*gradList)->stops);
//TODO: Properly inherit other property //TODO: Properly inherit other property
break; break;