Fix SVACE issue 41/231141/2
authorSeungho, Baek <sbsh.baek@samsung.com>
Fri, 17 Apr 2020 10:51:59 +0000 (19:51 +0900)
committerSeungho, Baek <sbsh.baek@samsung.com>
Fri, 17 Apr 2020 11:19:39 +0000 (20:19 +0900)
Change-Id: I39b3d15f8b4dd6940f93c9ec3cf6c9c4536e2105
Signed-off-by: Seungho, Baek <sbsh.baek@samsung.com>
dali-toolkit/internal/builder/builder-impl.cpp
dali-toolkit/third-party/nanosvg/nanosvg.cc
dali-toolkit/third-party/yoga/YGNode.cpp

index 78000be..f848b1d 100644 (file)
@@ -1336,7 +1336,10 @@ void Builder::RecordTransitionData(
     Dali::Property::Value property(Property::ARRAY);
     if( DeterminePropertyFromNode( keyValue.second, Property::ARRAY, property, replacements ) )
     {
-      transitionData = Toolkit::TransitionData::New( *property.GetArray() );
+      if( property.GetArray() )
+      {
+        transitionData = Toolkit::TransitionData::New( *property.GetArray() );
+      }
     }
   }
   else if( node.GetType() == TreeNode::OBJECT )
@@ -1344,7 +1347,10 @@ void Builder::RecordTransitionData(
     Dali::Property::Value property(Property::MAP);
     if( DeterminePropertyFromNode( keyValue.second, Property::MAP, property, replacements ) )
     {
-      transitionData = Toolkit::TransitionData::New( *property.GetMap() );
+      if( property.GetMap() )
+      {
+        transitionData = Toolkit::TransitionData::New( *property.GetMap() );
+      }
     }
   }
 }
index a99d1dd..89479fd 100755 (executable)
@@ -103,6 +103,14 @@ static void nsvg__parseElement(char* s,
        int end = 0;
        char quote;
 
+       /**
+        * In the original file, 's' is not compared to NULL value before it is dereferenced.
+        */
+       if (!s)
+       {
+               return;
+       }
+
        // Skip white space after the '<'
        while (*s && nsvg__isspace(*s)) s++;
 
@@ -800,7 +808,12 @@ static void nsvg__addShape(NSVGparser* p)
                return;
 
        shape = (NSVGshape*)malloc(sizeof(NSVGshape));
-       if (shape == NULL) goto error;
+
+       /**
+        * In the original file, if shape is NULL it goto error below 'return' and free shape memory.
+        * But, the error is only visited when shape is NULL, so there is not needed to free it.
+        */
+       if (shape == NULL) return;
        memset(shape, 0, sizeof(NSVGshape));
 
        memcpy(shape->id, attr->id, sizeof shape->id);
@@ -876,9 +889,6 @@ static void nsvg__addShape(NSVGparser* p)
        p->shapesTail = shape;
 
        return;
-
-error:
-       if (shape) free(shape);
 }
 
 static void nsvg__addPath(NSVGparser* p, char closed)
@@ -1279,7 +1289,7 @@ static unsigned int nsvg__parseColor(const char* str)
 
 static float nsvg__parseOpacity(const char* str)
 {
-       float val = nsvg__atof(str);\r
+       float val = nsvg__atof(str);
        if (val < 0.0f) val = 0.0f;
        if (val > 1.0f) val = 1.0f;
        return val;
@@ -2791,7 +2801,10 @@ NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi)
 error:
        if (fp) fclose(fp);
        if (data) free(data);
-       if (image) nsvgDelete(image);
+       /**
+        * In the original file, image has null check and free it here. But because image has data after all of the 'goto error',
+        * 'free(image)' was unreachable. So, we removed it.
+        */
        return NULL;
 }
 
index 6ebc69c..eec55de 100644 (file)
@@ -404,7 +404,11 @@ YGNode::YGNode()
       nextChild_(nullptr),
       config_(nullptr),
       isDirty_(false),
-      resolvedDimensions_({{YGValueUndefined, YGValueUndefined}}) {}
+      resolvedDimensions_(std::array<YGValue, 2>{YGValueUndefined, YGValueUndefined}) {}
+      /**
+       * In the original file, to initialize resolvedDimensions_ above, we usee { { YGValueUndefined, YGValueUndefined } }.
+       * But it is not well work, so we modified it.
+       */
 
 YGNode::YGNode(const YGNode& node)
     : context_(node.context_),