Fix dereferencing of null pointer in model::Layer::solidColor() getter
authorNicholas Guriev <nicholas@guriev.su>
Thu, 27 May 2021 12:01:58 +0000 (15:01 +0300)
committerHermet Park <chuneon.park@samsung.com>
Mon, 21 Jun 2021 02:52:30 +0000 (11:52 +0900)
Also remove unnecessarily check of mExtra->mAsset in the asset() getter.

Change-Id: Ic17532314309e331be28bd09d9af63208ac0690b

src/lottie/lottiemodel.h

index 977e808ba4683b920cdf0802f3948a5819a95ed6..c6b8cf6d5c43e959711477d472d29b76076a58fe 100644 (file)
@@ -687,7 +687,10 @@ public:
     int     inFrame() const noexcept { return mInFrame; }
     int     outFrame() const noexcept { return mOutFrame; }
     int     startFrame() const noexcept { return mStartFrame; }
-    Color   solidColor() const noexcept { return mExtra->mSolidColor; }
+    Color   solidColor() const noexcept
+    {
+        return mExtra ? mExtra->mSolidColor : Color();
+    }
     bool    autoOrient() const noexcept { return mAutoOrient; }
     int     timeRemap(int frameNo) const;
     VSize   layerSize() const { return mLayerSize; }
@@ -701,10 +704,7 @@ public:
     {
         return mTransform ? mTransform->opacity(frameNo) : 1.0f;
     }
-    Asset *asset() const
-    {
-        return (mExtra && mExtra->mAsset) ? mExtra->mAsset : nullptr;
-    }
+    Asset *asset() const { return mExtra ? mExtra->mAsset : nullptr; }
     struct Extra {
         Color               mSolidColor;
         std::string         mPreCompRefId;