• With issues:
  • Use the search tool before opening a new issue.
  • Please provide source code and commit sha if you found a bug.
  • Review existing issues and provide feedback or react to them.

Description

when there is no value for the 'Parent' field, the mapping maybe infinite recurse.

// form_mapping_test.go
func TestInfiniteRecursion(t *testing.T) {
    type Req struct {
        Parent *Req `form:"parent"`
    }
    var s = Req{}
    err := mappingByPtr(&s, formSource{}, "form")
    assert.NoError(t, err)
}

example: my struct is below, the 'Foo2' maybe pass by query. But sometimes, I forget to pass 'foo2' in query parameters, the server will over stack

    type Req struct {
        Foo  string `form:"foo"`
        Bar  string `form:"bar"`
        Foo1 string `form:"Foo"`
        Bar1 string `form:"Bar"`
        Foo2 *Req   `form:"foo2"`
    }

How to reproduce

// form_mapping_test.go
func TestInfiniteRecursion(t *testing.T) {
    type Req struct {
        Parent *Req `form:"parent"`
    }
    var s = Req{}
    err := mappingByPtr(&s, formSource{}, "form")
    assert.NoError(t, err)
}

Expectations

binding successfully or error, but not stack overflow

Actual result

Gin binding maybe infinite recurse

Environment