-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Memory.store_n and Helpers.slice_data for border cases (#217)
<!--- Please provide a general summary of your changes in the title above --> ## Pull request type <!-- Please try to limit your pull request to one type, submit multiple pull requests if needed. --> Please check the type of change your PR introduces: - [x] Bugfix - [ ] Feature - [ ] Code style update (formatting, renaming) - [ ] Refactoring (no functional changes, no api changes) - [ ] Build related changes - [ ] Documentation content changes - [ ] Other (please describe): ## What is the current behavior? <!-- Please describe the current behavior that you are modifying, or link to a relevant issue. --> Adding test cases to the opcode 0x39 led to 2 failures. The failures have been identified to be linked to corner cases in Memory.store_n and Helpers.slice_data. Such a corner case is for example when taking a slice with offset out of bound. Issue Number: related to 98 ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> Tests for the CODECOPY (0x39) opcode have been extended with more cases taking different code-paths. Memory.store_n and Helpers.slice_data have been reimplemented to cover all cases. Cases for slice_data: 1. slice fully overlaps with data: data_offset + slice_len <= data_len 2. slice partially overlaps with data: data_offset < data_len < data_offset + slice_len 3. slice does not overlap with data: data_len <= data_offset For Memory.store_n, the new memory is composed of 3 parts: 1. Head: current bytes before offset. Might be zero padded in case len < offset 2. New elements: always inserted between offset and offset + element_len 3. Tail: current bytes after the new elements. Might be zero padded in case total memory length is not a multiple of 32 ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Co-authored-by: Thomas Zamojski <thomas.zamojski@datastorm.fr>
- Loading branch information
1 parent
c957030
commit 6d49758
Showing
6 changed files
with
170 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters