Skip to content

fix: handle offset views correctly#40

Merged
nathanosdev merged 1 commit into
mainfrom
nathan/handle-offset-views-correctly
Jun 17, 2025
Merged

fix: handle offset views correctly#40
nathanosdev merged 1 commit into
mainfrom
nathan/handle-offset-views-correctly

Conversation

@nathanosdev

Copy link
Copy Markdown
Contributor

It's possible for a consumer to pass in a Uin8Array that is pointing at some offset of the underlying ArrayBuffer. This is fine for most of the code in this library, except when we create our own DataView on the underlying ArrayBuffer. Previously we were creating that DataView at the 0 index of the underlying ArrayBuffer, now we create it at Uint8Array.offset instead to ensure we do not read the wrong indexes.

@nathanosdev nathanosdev self-assigned this Jun 17, 2025
Comment thread README.md
Comment thread src/decode/decode.spec.ts
Comment thread src/decode/decode.spec.ts
Comment thread src/decode/decode.ts
Comment thread src/decode/decode.ts
@nathanosdev nathanosdev marked this pull request as ready for review June 17, 2025 11:54
@nathanosdev nathanosdev requested a review from a team as a code owner June 17, 2025 11:54

@ilbertt ilbertt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great fix!

@nathanosdev nathanosdev added this pull request to the merge queue Jun 17, 2025
Merged via the queue into main with commit 6a67dac Jun 17, 2025
10 checks passed
@nathanosdev nathanosdev deleted the nathan/handle-offset-views-correctly branch June 17, 2025 12:05
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