jarvis657 / goprotobuf

Automatically exported from code.google.com/p/goprotobuf
Other
0 stars 0 forks source link

panic on SetDefaults on optional nil sub-message #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a protobuf message with an optional sub-message.
2. Create pbstruct := &ProtobufMessage{}, but don't set sub-message.
2. Call proto.SetDefaults(pbstruct)

What is the expected output? What do you see instead?
I wasn't sure if this is supported, maybe it's expected that all fields are 
initialized?

What version of the product are you using? On what operating system?
tip (121:211d266ef4cf).

Please provide any additional information below.
The subsceding call to setDefaults(v.Field(ni)) fails.

goroutine 1 [running]:
reflect.Value.Type(0x0, 0x0, 0x0, 0x0, 0x0, ...)
    go/src/pkg/reflect/value.go:1406 +0x78
goprotobuf.googlecode.com/hg/proto.setDefaults(0x0, 0x0, 0x0, 0x1, 0x4c4280, 
...)
    goprotobuf/proto/lib.go:562 +0x74
goprotobuf.googlecode.com/hg/proto.setDefaults(0x4c79b0, 0xf840019db0, 0x196, 
0x1, 0xf840019db0, ...)
    goprotobuf/proto/lib.go:660 +0x32c
goprotobuf.googlecode.com/hg/proto.SetDefaults(0x4c44b0, 0xf840019db0)
    goprotobuf/proto/lib.go:554 +0xad

Original issue reported on code.google.com by o.pers...@gmail.com on 5 Dec 2011 at 3:38

Attachments:

GoogleCodeExporter commented 9 years ago
This is the patch I tried to send.

Original comment by o.pers...@gmail.com on 5 Dec 2011 at 3:40

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by dsymo...@golang.org on 8 Dec 2011 at 2:16

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 9f5b1680073b.

Original comment by dsymo...@golang.org on 12 Dec 2011 at 10:10