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

safer out of bounds #1135

Merged
merged 1 commit into from
Mar 29, 2023
Merged

safer out of bounds #1135

merged 1 commit into from
Mar 29, 2023

Conversation

zricethezav
Copy link
Collaborator

Description:

Fixes #1132

Checklist:

  • Does your PR pass tests?
  • Have you written new tests for your changes?
  • Have you lint your code locally prior to submission?

@zricethezav zricethezav merged commit 56079dc into master Mar 29, 2023
@zricethezav zricethezav deleted the safer-out-of-bounds branch March 29, 2023 13:37
Comment on lines +125 to +132

lineEndIdx := matchInLineIDX + len(f.Match)
if len(f.Line)-1 <= lineEndIdx {
lineEndIdx = len(f.Line) - 1
}

lineEnd := f.Line[matchInLineIDX+len(f.Match):]

Copy link

Choose a reason for hiding this comment

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

@zricethezav
As noted in #1145, this PR didn't solve the issue.
Maybe you meant to fix the issue as suggested below?

Suggested change
lineEndIdx := matchInLineIDX + len(f.Match)
if len(f.Line)-1 <= lineEndIdx {
lineEndIdx = len(f.Line) - 1
}
lineEnd := f.Line[matchInLineIDX+len(f.Match):]
lineEndIdx := matchInLineIDX + len(f.Match)
if len(f.Line)-1 <= lineEndIdx {
lineEndIdx = len(f.Line) - 1
}
lineEnd := f.Line[lineEndIdx:]

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.

Slice bounds out of range panic in v8.15.2-v8.16.1
2 participants