lottie/parser: check for layer data integrity
authorsubhransu mohanty <sub.mohanty@samsung.com>
Thu, 5 Sep 2019 08:20:42 +0000 (17:20 +0900)
committerHermet Park <hermetpark@gmail.com>
Tue, 17 Sep 2019 01:23:25 +0000 (10:23 +0900)
this patch checkes if the layer has assigned itself as parent.

Change-Id: I3c46242adf741efb0ac06ca742cc224675bd7474

src/lottie/lottiemodel.h
src/lottie/lottieparser.cpp

index 8e98af0..4515895 100644 (file)
@@ -574,6 +574,7 @@ public:
     bool hasRepeater() const noexcept {return mHasRepeater;}
     int id() const noexcept{ return mId;}
     int parentId() const noexcept{ return mParentId;}
+    bool hasParent() const noexcept {return mParentId != -1;}
     int inFrame() const noexcept{return mInFrame;}
     int outFrame() const noexcept{return mOutFrame;}
     int startFrame() const noexcept{return mStartFrame;}
index c8974c7..aab1275 100644 (file)
@@ -933,6 +933,9 @@ std::shared_ptr<LOTData> LottieParserImpl::parseLayer(bool record)
         return nullptr;
     }
 
+    // make sure layer data is not corrupted.
+    if (layer->hasParent() && (layer->id() == layer->parentId())) return nullptr;
+
     if (layer->mExtra) layer->mExtra->mCompRef = compRef;
 
     if (layer->hidden()) {
@@ -2120,7 +2123,7 @@ public:
 
     void visit(LOTData *obj, std::string level)
     {
-        switch (obj->mType) {
+        switch (obj->type()) {
         case LOTData::Type::Repeater: {
             auto r = static_cast<LOTRepeaterData *>(obj);
             vDebug << level << "{ Repeater: name: " << obj->name()