forked from mirror/gin
Fix insufficient slice check (#2755)
This commit is contained in:
parent
f2bbdfe9f2
commit
1d0f938f28
2
tree.go
2
tree.go
|
@ -459,7 +459,7 @@ walk: // Outer loop for walking the tree
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save param value
|
// Save param value
|
||||||
if params != nil {
|
if params != nil && cap(*params) > 0 {
|
||||||
if value.params == nil {
|
if value.params == nil {
|
||||||
value.params = params
|
value.params = params
|
||||||
}
|
}
|
||||||
|
|
13
tree_test.go
13
tree_test.go
|
@ -717,6 +717,19 @@ func TestTreeInvalidNodeType(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTreeInvalidParamsType(t *testing.T) {
|
||||||
|
tree := &node{}
|
||||||
|
tree.wildChild = true
|
||||||
|
tree.children = append(tree.children, &node{})
|
||||||
|
tree.children[0].nType = 2
|
||||||
|
|
||||||
|
// set invalid Params type
|
||||||
|
params := make(Params, 0, 0)
|
||||||
|
|
||||||
|
// try to trigger slice bounds out of range with capacity 0
|
||||||
|
tree.getValue("/test", ¶ms, false)
|
||||||
|
}
|
||||||
|
|
||||||
func TestTreeWildcardConflictEx(t *testing.T) {
|
func TestTreeWildcardConflictEx(t *testing.T) {
|
||||||
conflicts := [...]struct {
|
conflicts := [...]struct {
|
||||||
route string
|
route string
|
||||||
|
|
Loading…
Reference in New Issue