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

[Merged by Bors] - Fix casting negative number to usize in Array.splice #2030

Closed
wants to merge 1 commit into from

Conversation

lupd
Copy link
Contributor

@lupd lupd commented Apr 14, 2022

This Pull Request fixes a faulty cast for Array.splice.

Negative values for delete_count were being directly casted to usize, which was not the intended behavior. This pull request fixes the issue by using a fallible conversion, defaulting to 0 if the conversion fails.

It changes the following:

  • Replace cast in Array.splice prototype method with fallible conversion.

@codecov
Copy link

codecov bot commented Apr 14, 2022

Codecov Report

Merging #2030 (b292a8a) into main (34303f1) will decrease coverage by 0.00%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #2030      +/-   ##
==========================================
- Coverage   44.15%   44.14%   -0.01%     
==========================================
  Files         210      210              
  Lines       18596    18594       -2     
==========================================
- Hits         8211     8209       -2     
  Misses      10385    10385              
Impacted Files Coverage Δ
boa_engine/src/builtins/array/mod.rs 75.70% <ø> (ø)
boa_engine/src/syntax/lexer/template.rs 36.36% <0.00%> (-2.77%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34303f1...b292a8a. Read the comment docs.

@raskad
Copy link
Member

raskad commented Apr 14, 2022

VM implementation

Test result main count PR count difference
Total 88,720 88,720 0
Passed 53,146 53,164 +18
Ignored 21,853 21,853 0
Failed 13,721 13,703 -18
Panics 0 0 0
Conformance 59.90% 59.92% +0.02%
Fixed tests (18):
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T4.js [strict mode] (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T4.js (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T1.js [strict mode] (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T1.js (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T1.js [strict mode] (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T1.js (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T3.js [strict mode] (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T3.js (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T5.js [strict mode] (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T5.js (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T3.js [strict mode] (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.3_T3.js (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A2_T3.js [strict mode] (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A2_T3.js (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A2_T2.js [strict mode] (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A2_T2.js (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T2.js [strict mode] (previously Failed)
test/built-ins/Array/prototype/splice/S15.4.4.12_A1.2_T2.js (previously Failed)

@raskad raskad added this to the v0.15.0 milestone Apr 14, 2022
@raskad raskad added bug Something isn't working builtins PRs and Issues related to builtins/intrinsics labels Apr 14, 2022
Copy link
Member

@jedel1043 jedel1043 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@raskad
Copy link
Member

raskad commented Apr 14, 2022

bors r+

bors bot pushed a commit that referenced this pull request Apr 14, 2022
This Pull Request fixes a faulty cast for `Array.splice`. 

Negative values for delete_count were being directly casted to usize, which was not the intended behavior. This pull request fixes the issue by using a fallible conversion, defaulting to 0 if the conversion fails.

It changes the following:

- Replace cast in `Array.splice` prototype method with fallible conversion.
@bors
Copy link

bors bot commented Apr 14, 2022

Pull request successfully merged into main.

Build succeeded:

@bors bors bot changed the title Fix casting negative number to usize in Array.splice [Merged by Bors] - Fix casting negative number to usize in Array.splice Apr 14, 2022
@bors bors bot closed this Apr 14, 2022
Razican pushed a commit that referenced this pull request Jun 8, 2022
This Pull Request fixes a faulty cast for `Array.splice`. 

Negative values for delete_count were being directly casted to usize, which was not the intended behavior. This pull request fixes the issue by using a fallible conversion, defaulting to 0 if the conversion fails.

It changes the following:

- Replace cast in `Array.splice` prototype method with fallible conversion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants