Skip to content

Commit

Permalink
coerce negative set size in get-set-record to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Jan 16, 2023
1 parent 9f9bc14 commit 20ab9c5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## Changelog
##### Unreleased
- [`Set` methods proposal](https://github.com/tc39/proposal-set-methods) minor updates:
- [`Set` methods proposal](https://github.com/tc39/proposal-set-methods) updates:
- Closing of iterators of `Set`-like objects on early exit, [proposal-set-methods/85](https://github.com/tc39/proposal-set-methods/pull/85)
- Some other minor internal changes
- Added one more workaround of a `webpack` dev server bug on IE global methods, [#1161](https://github.com/zloirock/core-js/issues/1161)
- Fixed possible `String.{ raw, cooked }` error with empty template array
- Used non-standard V8 `Error.captureStackTrace` instead of stack parsing in new error classes / wrappers where it's possible
Expand Down
3 changes: 2 additions & 1 deletion packages/core-js/internals/get-set-record.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ var call = require('../internals/function-call');
var toIntegerOrInfinity = require('../internals/to-integer-or-infinity');

var $TypeError = TypeError;
var max = Math.max;

var SetRecord = function (set, size, has, keys) {
this.set = set;
Expand Down Expand Up @@ -31,7 +32,7 @@ module.exports = function (obj) {
if (numSize != numSize) throw $TypeError('Invalid size');
return new SetRecord(
obj,
toIntegerOrInfinity(numSize),
max(toIntegerOrInfinity(numSize), 0),
aCallable(obj.has),
aCallable(obj.keys)
);
Expand Down

0 comments on commit 20ab9c5

Please sign in to comment.