Skip to content

Commit

Permalink
feat: fix slice bound out of range due to incorrect usage of slice.Grow
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerwill90 committed Jul 15, 2024
1 parent b92f025 commit 8967adb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion context.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func (c *cTx) CloneWith(w ResponseWriter, r *http.Request) ContextCloser {
cp.cachedQuery = nil
if cap(*c.params) > cap(*cp.params) {
// Grow cp.params to a least cap(c.params)
*cp.params = slices.Grow(*cp.params, cap(*c.params)-cap(*cp.params))
*cp.params = slices.Grow(*cp.params, cap(*c.params))

Check warning on line 318 in context.go

View check run for this annotation

Codecov / codecov/patch

context.go#L318

Added line #L318 was not covered by tests
}
// cap(cp.params) >= cap(c.params)
// now constraint into len(c.params) & cap(c.params)
Expand Down
8 changes: 4 additions & 4 deletions tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ Walk:
if !lazy {
if cap(*c.params) > cap(*c.tsrParams) {
// Grow c.tsrParams to a least cap(c.params)
*c.tsrParams = slices.Grow(*c.tsrParams, cap(*c.params)-cap(*c.tsrParams))
*c.tsrParams = slices.Grow(*c.tsrParams, cap(*c.params))

Check warning on line 654 in tree.go

View check run for this annotation

Codecov / codecov/patch

tree.go#L654

Added line #L654 was not covered by tests
}
// cap(c.tsrParams) >= cap(c.params)
// now constraint into len(c.params) & cap(c.params)
Expand Down Expand Up @@ -693,7 +693,7 @@ Walk:
if !lazy {
if cap(*c.params) > cap(*c.tsrParams) {
// Grow c.tsrParams to a least cap(c.params)
*c.tsrParams = slices.Grow(*c.tsrParams, cap(*c.params)-cap(*c.tsrParams))
*c.tsrParams = slices.Grow(*c.tsrParams, cap(*c.params))

Check warning on line 696 in tree.go

View check run for this annotation

Codecov / codecov/patch

tree.go#L696

Added line #L696 was not covered by tests
}
// cap(c.tsrParams) >= cap(c.params)
// now constraint into len(c.params) & cap(c.params)
Expand All @@ -711,7 +711,7 @@ Walk:
if !lazy {
if cap(*c.params) > cap(*c.tsrParams) {
// Grow c.tsrParams to a least cap(c.params)
*c.tsrParams = slices.Grow(*c.tsrParams, cap(*c.params)-cap(*c.tsrParams))
*c.tsrParams = slices.Grow(*c.tsrParams, cap(*c.params))

Check warning on line 714 in tree.go

View check run for this annotation

Codecov / codecov/patch

tree.go#L714

Added line #L714 was not covered by tests
}
// cap(c.tsrParams) >= cap(c.params)
// now constraint into len(c.params) & cap(c.params)
Expand Down Expand Up @@ -752,7 +752,7 @@ Walk:
if !lazy {
if cap(*c.params) > cap(*c.tsrParams) {
// Grow c.tsrParams to a least cap(c.params)
*c.tsrParams = slices.Grow(*c.tsrParams, cap(*c.params)-cap(*c.tsrParams))
*c.tsrParams = slices.Grow(*c.tsrParams, cap(*c.params))

Check warning on line 755 in tree.go

View check run for this annotation

Codecov / codecov/patch

tree.go#L755

Added line #L755 was not covered by tests
}
// cap(c.tsrParams) >= cap(c.params)
// now constraint into len(c.params) & cap(c.params)
Expand Down

0 comments on commit 8967adb

Please sign in to comment.