lottie-colorify icon indicating copy to clipboard operation
lottie-colorify copied to clipboard

[BUG] Missed null value checking inside of doReplace function

Open v-honcharenko opened this issue 1 year ago • 0 comments

Hi @xxmuaddib !

In some cases, the object that is passed to the doReplace function may be equal to null. The basic checking typeof obj[key] === 'object' doesn't work in this case, because the null value passes it. To solve the issue only one check for the obj[key] value existence should be to added here.

Here is the diff that solved my problem:

diff --git a/node_modules/lottie-colorify/lib/index.js b/node_modules/lottie-colorify/lib/index.js
index 1b5ee90..f764a65 100644
--- a/node_modules/lottie-colorify/lib/index.js
+++ b/node_modules/lottie-colorify/lib/index.js
@@ -73,7 +73,7 @@ exports.replaceColor = function (sourceColor, targetColor, lottieObj) {
         }
         else {
             for (var key in obj) {
-                if (typeof obj[key] === 'object') {
+                if (obj[key] && typeof obj[key] === 'object') {
                     doReplace(sourceLottieColor, targetLottieColor, obj[key]);
                 }
             }

This issue body was partially generated by patch-package.

v-honcharenko avatar May 29 '23 17:05 v-honcharenko