Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when modifying array length #89

Merged
merged 1 commit into from
Jan 22, 2022

Conversation

Jimbly
Copy link
Contributor

@Jimbly Jimbly commented Jan 1, 2022

Also avoids unnecessary allocation and set.

Fixes cases like the following:

let obj = { a: [1,2] };
dotProp.delete(obj, 'a.1');
dotProp.set(obj, 'a.length', 1);

Previously would throw Uncaught RangeError: Invalid array length when it tries to set obj.a.length = {}

@sindresorhus
Copy link
Owner

Can you add a test?

Also avoids unnecessary allocation and set.

Fixes cases like the following:
```javascript
let obj = { a: [1,2] };
dotProp.delete(obj, 'a.1');
dotProp.set(obj, 'a.length', 1);
```
Previously would throw `Uncaught RangeError: Invalid array length` when it tries to set `obj.a.length = {}`
@Jimbly
Copy link
Contributor Author

Jimbly commented Jan 22, 2022

Merge conflicts resolved and test added (also verified the test still fails on main).

@sindresorhus sindresorhus changed the title Fix crashing modifying array length Fix crash when modifying array length Jan 22, 2022
@sindresorhus sindresorhus merged commit d363922 into sindresorhus:main Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants