Skip to content

Commit

Permalink
Fix nil pointer panic in encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
rekby authored and fiorix committed Jun 25, 2018
1 parent 42d6ed1 commit 3937e21
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions wsdlgo/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1303,8 +1303,14 @@ func (ge *goEncoder) genGoStruct(w io.Writer, d *wsdl.Definitions, ct *wsdl.Comp
fmt.Fprintf(w, "type %s interface{}\n\n", name)
return nil
}
if (ct.Sequence != nil && ct.Sequence.Any != nil) || (ct.Choice != nil && ct.Choice.Any != nil) {
if len(ct.Sequence.Elements) == 0 || len(ct.Choice.Elements) == 0 {
if ct.Sequence != nil && ct.Sequence.Any != nil {
if len(ct.Sequence.Elements) == 0 {
fmt.Fprintf(w, "type %s []interface{}\n\n", name)
return nil
}
}
if ct.Choice != nil && ct.Choice.Any != nil {
if len(ct.Choice.Elements) == 0 {
fmt.Fprintf(w, "type %s []interface{}\n\n", name)
return nil
}
Expand Down Expand Up @@ -1487,7 +1493,7 @@ func (ge *goEncoder) genElementField(w io.Writer, el *wsdl.Element) {
var slicetype string
if el.Type == "" && el.ComplexType != nil {
seq := el.ComplexType.Sequence
if seq == nil {
if seq == nil && el.ComplexType.Choice != nil {
seq = &wsdl.Sequence{
ComplexTypes: el.ComplexType.Choice.ComplexTypes,
Elements: el.ComplexType.Choice.Elements,
Expand Down

0 comments on commit 3937e21

Please sign in to comment.