From 632880eb0b98d5ca36608cbe1509d10bb56e5dc9 Mon Sep 17 00:00:00 2001 From: "Seungho, Baek" Date: Fri, 17 Apr 2020 19:51:59 +0900 Subject: [PATCH] Fix SVACE issue Change-Id: I39b3d15f8b4dd6940f93c9ec3cf6c9c4536e2105 Signed-off-by: Seungho, Baek --- dali-toolkit/internal/builder/builder-impl.cpp | 10 ++++++++-- dali-toolkit/third-party/nanosvg/nanosvg.cc | 25 +++++++++++++++++++------ dali-toolkit/third-party/yoga/YGNode.cpp | 6 +++++- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/dali-toolkit/internal/builder/builder-impl.cpp b/dali-toolkit/internal/builder/builder-impl.cpp index 78000be..f848b1d 100644 --- a/dali-toolkit/internal/builder/builder-impl.cpp +++ b/dali-toolkit/internal/builder/builder-impl.cpp @@ -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() ); + } } } } diff --git a/dali-toolkit/third-party/nanosvg/nanosvg.cc b/dali-toolkit/third-party/nanosvg/nanosvg.cc index a99d1dd..89479fd 100755 --- a/dali-toolkit/third-party/nanosvg/nanosvg.cc +++ b/dali-toolkit/third-party/nanosvg/nanosvg.cc @@ -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); + 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; } diff --git a/dali-toolkit/third-party/yoga/YGNode.cpp b/dali-toolkit/third-party/yoga/YGNode.cpp index 6ebc69c..eec55de 100644 --- a/dali-toolkit/third-party/yoga/YGNode.cpp +++ b/dali-toolkit/third-party/yoga/YGNode.cpp @@ -404,7 +404,11 @@ YGNode::YGNode() nextChild_(nullptr), config_(nullptr), isDirty_(false), - resolvedDimensions_({{YGValueUndefined, YGValueUndefined}}) {} + resolvedDimensions_(std::array{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_), -- 2.7.4