Skip to content

Commit

Permalink
fix: nil pointer dereference fix fiorix#132
Browse files Browse the repository at this point in the history
  • Loading branch information
Denys Vitali committed Jun 26, 2020
1 parent 5100b2d commit fbe6614
Show file tree
Hide file tree
Showing 6 changed files with 4,426 additions and 16 deletions.
34 changes: 18 additions & 16 deletions wsdlgo/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -1369,24 +1369,26 @@ func (ge *goEncoder) genGoOpStruct(w io.Writer, d *wsdl.Definitions, bo *wsdl.Bi
name := goSymbol(bo.Name)
function := ge.funcs[name]

if function.Input == nil {
log.Printf("function input is nil! %v is %v", name, function)
} else {
message := trimns(function.Input.Message)
inputMessage := ge.messages[message]
if function != nil {
if function.Input == nil {
log.Printf("function input is nil! %v is %v", name, function)
} else {
message := trimns(function.Input.Message)
inputMessage := ge.messages[message]

// No-Op on operations which don't take arguments
// (These can be inlined, and don't need to pollute the file)
if len(inputMessage.Parts) > 0 {
ge.genOpStructMessage(w, d, name, inputMessage)
// No-Op on operations which don't take arguments
// (These can be inlined, and don't need to pollute the file)
if len(inputMessage.Parts) > 0 {
ge.genOpStructMessage(w, d, name, inputMessage)
}
}
}

if function.Output == nil {
log.Printf("function output is nil! %v is %v", name, function)
} else {
// Output messages are always required
ge.genOpStructMessage(w, d, name, ge.messages[trimns(ge.funcs[bo.Name].Output.Message)])
if function.Output == nil {
log.Printf("function output is nil! %v is %v", name, function)
} else {
// Output messages are always required
ge.genOpStructMessage(w, d, name, ge.messages[trimns(ge.funcs[bo.Name].Output.Message)])
}
}

return nil
Expand Down Expand Up @@ -1508,7 +1510,7 @@ func (ge *goEncoder) genSimpleContent(w io.Writer, d *wsdl.Definitions, ct *wsdl
ext := ct.SimpleContent.Extension
if ext.Base != "" {
baseComplex, exists := ge.ctypes[trimns(ext.Base)]
if exists {
if exists && strings.Index(baseComplex.TargetNamespace,"http://www.w3.org/") != 0 {
err := ge.genStructFields(w, d, baseComplex)
if err != nil {
return err
Expand Down
2 changes: 2 additions & 0 deletions wsdlgo/encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ var EncoderCases = []struct {
{F: "localimport-url.wsdl", G: "localimport.golden", E: nil},
{F: "localimport_choice.wsdl", G: "localimport_choice.golden", E: nil},
{F: "arrayexample.wsdl", G: "arrayexample.golden", E: nil},
{F: "radioreference.wsdl", G: "radioreference.golden", E: nil},
{F: "scannerservice.wsdl", G: "scannerservice.golden", E: nil},
}

func NewTestServer(t *testing.T) *httptest.Server {
Expand Down
Loading

0 comments on commit fbe6614

Please sign in to comment.