svg_loader: fixing segf when passing a nullptr to strcmp 33/289333/1
authormgrudzinska <m.grudzinska@samsung.com>
Sun, 3 Apr 2022 20:32:26 +0000 (22:32 +0200)
committerMichal Szczecinski <mihashco89@gmail.com>
Mon, 6 Mar 2023 10:00:15 +0000 (11:00 +0100)
This occurred when a gradient has no 'id' attribute.

Change-Id: I8b4204a657e4ea6fd298bcbfd244a09a46f05d11

src/loaders/svg/tvgSvgLoader.cpp

index 674fbb9..cb056c4 100644 (file)
@@ -2872,7 +2872,7 @@ static SvgStyleGradient* _gradientDup(Array<SvgStyleGradient*>* gradients, const
     auto gradList = gradients->data;
 
     for (uint32_t i = 0; i < gradients->count; ++i) {
-        if (!strcmp((*gradList)->id, id)) {
+        if ((*gradList)->id && !strcmp((*gradList)->id, id)) {
             result = _cloneGradient(*gradList);
             break;
         }
@@ -2882,7 +2882,7 @@ static SvgStyleGradient* _gradientDup(Array<SvgStyleGradient*>* gradients, const
     if (result && result->ref) {
         gradList = gradients->data;
         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);
                 //TODO: Properly inherit other property
                 break;