Skip to content

Commit 5a3d2a6

Browse files
committed
tighten array handling in relinkPrivateKeys
1 parent 3e22d38 commit 5a3d2a6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib/relink_private.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) {
4343
if(k === 'customdata' || k === 'ids') continue;
4444

4545
// recurse into arrays containers
46-
for(var j = 0; j < fromVal.length; j++) {
47-
if(isPlainObject(fromVal[j]) && isPlainObject(toVal[j]) && (toVal[j] !== fromVal[j])) {
46+
var minLen = Math.min(fromVal.length, toVal.length);
47+
for(var j = 0; j < minLen; j++) {
48+
if((toVal[j] !== fromVal[j]) && isPlainObject(fromVal[j]) && isPlainObject(toVal[j])) {
4849
relinkPrivateKeys(toVal[j], fromVal[j]);
4950
}
5051
}

0 commit comments

Comments
 (0)