Skip to content

Commit 5c94164

Browse files
authored
fix: Fix config failures with multiple references to an input array (#8585)
When the user passes an array-based config, we should never copy the reference. Instead, we should clone the array. This way, changes to that outside array don't immediately affect the running config. Closes #8478
1 parent 59a1254 commit 5c94164

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/util/config_utils.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ shaka.util.ConfigUtils = class {
101101
shaka.log.alwaysWarn(
102102
'Unexpected number of arguments for ' + subPath);
103103
destination[k] = source[k];
104+
} else if (Array.isArray(destination[k])) {
105+
// Make a copy of the input array, so that changes to the source object
106+
// don't immediately affect the running config.
107+
// Since everything here is very loosely-typed, use a cast to convince
108+
// the compiler we're not calling slice() on a potential ArrayBuffer,
109+
// which would break Tizen.
110+
destination[k] = /** @type {Array} */(source[k]).slice();
104111
} else {
105112
destination[k] = source[k];
106113
}

0 commit comments

Comments
 (0)