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

encoder: match buffer length when capacity grows #161

Merged
merged 2 commits into from
Feb 19, 2025

Conversation

lgfa29
Copy link
Contributor

@lgfa29 lgfa29 commented Feb 19, 2025

The Buffer data structure has an internal byte slice that is expanded when the Grow() method is called. Since the effective buffer length is tracked using the offset variable, the underlying slice length must also be expanded to match its new capacity, otherwise accessing b.b[b.offset] may result in an index out of range runtime panic.

The `Buffer` data structure has an internal byte slice that is expanded
when the `Grow()` method is called. Since the effective buffer length is
tracked using the `offset` variable, the underlying slice length must
also be expanded to match its new capacity, otherwise accessing
`b.b[b.offset]` may result in an `index out of range` runtime panic.

Signed-off-by: Luiz Aoqui <[email protected]>
@lgfa29 lgfa29 force-pushed the fix-enconding-index-error branch from ca56c08 to 8300c51 Compare February 19, 2025 15:11
@lgfa29
Copy link
Contributor Author

lgfa29 commented Feb 19, 2025

CI error is unrelated and fixed in #162

Copy link
Contributor

@SuperManifolds SuperManifolds left a comment

Choose a reason for hiding this comment

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

LGTM

@SuperManifolds SuperManifolds merged commit 1a17840 into main Feb 19, 2025
9 checks passed
@SuperManifolds SuperManifolds deleted the fix-enconding-index-error branch February 19, 2025 16:19
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