Skip to content

Fix exception when parsing with sliced Data #16

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
merged 3 commits into from
Oct 19, 2021

Conversation

joskuijpers
Copy link
Contributor

When a Data input is used that has a slice started beyond 0, an exception was thrown because the parser tried to access index 0.

See for example https://stackoverflow.com/questions/54698947/swift-data-subdata-fails-with-exc-bad-instruction-code-exc-i386-invop-subcode for an explanation.

All that was needed to fix it was to start at data.startIndex and finishes before data.endIndex.
I also added a testcase that failed before my change and succeeds after my changes. The rest of the cases still run.

Data uses slices which may not start at 0. When a Data is supplied which does not start at 0, the first index previously used would throw a bad access exception.

This happened for example with a Data value returns from CBOR previously. It does not per-se start with a slice at 0.
@joskuijpers
Copy link
Contributor Author

Hmm no idea why it is failing. I removed the whitespace already...

roxiemobile-forks added a commit to roxiemobile-forks/CBORCoding that referenced this pull request May 2, 2021
roxiemobile-forks added a commit to roxiemobile-forks/CBORCoding that referenced this pull request May 2, 2021
@SomeRandomiOSDev SomeRandomiOSDev merged commit 970994d into SomeRandomiOSDev:main Oct 19, 2021
@SomeRandomiOSDev
Copy link
Owner

@joskuijpers I pulled your commits and made a few additional updates to yours and merged it with PR #18

roxiemobile-forks added a commit to roxiemobile-forks/CBORCoding that referenced this pull request Mar 21, 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