Closed rzajac closed 5 months ago
Hi @rzajac, do you have an example that triggers a panic ? I think that if f
is nil
than v
will be nil
as well, and therefore the closure will return always "null" value, so f(v.Elem())
statement will not be reached
I tried to trigger the case you mentionned but I was not able to
func TestNilPointerDeference(t *testing.T) {
type C struct {
R int `schema:"R"`
}
type B struct {
C *C `schema:"C"`
}
b := B{C: (*C)(nil)}
encoder := NewEncoder()
vals := url.Values{}
if err := encoder.Encode(b, vals); err != nil {
t.Fatalf(err.Error())
}
}
The test is passing without errors.
@elithrar this can be closed I think
Thanks heaps @zak905 closing
sure thing!
https://github.com/gorilla/schema/blob/8285576f31afd6804df356a38883f4fa05014373/encoder.go#L167-L173
The
f
should be checked fornil
before it is used in closure.