Skip to content

Commit 9506e09

Browse files
committed
sanitize deleteCount to not exceed length / amount of items from index to end
1 parent 7150a70 commit 9506e09

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

warp-drive-packages/core/src/store/-private/record-arrays/legacy-many-array.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,11 @@ function _MUTATE<T>(
342342
}
343343
}
344344

345+
// sanitize deleteCount to not exceed length / amount of items from index to end
346+
deleteCount = Math.min(collection[Context].source.length - start, deleteCount);
347+
345348
// detect a full replace
346-
if (start === 0 && deleteCount >= collection[Context].source.length) {
349+
if (start === 0 && deleteCount === collection[Context].source.length) {
347350
const newValues = extractIdentifiersFromRecords(adds);
348351

349352
assertNoDuplicates(

0 commit comments

Comments
 (0)