Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: nil pointer dereference fix #132 #135

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function := ge.funcs[name] should be function := ge.funcs[bo.Name] and the whole issue is fixed.
No other changes are required.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this fix doesn't seem to work with other wsdls, unfortunately :(


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