Skip to content

Commit

Permalink
fix nil-dereference panic (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
jhump authored May 12, 2023
1 parent 0efcfa6 commit d5b8e4d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,10 @@ func invokeServerStream(ctx context.Context, stub grpcdynamic.Stub, md *desc.Met
// Now we can actually invoke the RPC!
str, err := stub.InvokeRpcServerStream(ctx, md, req)

if respHeaders, err := str.Header(); err == nil {
handler.OnReceiveHeaders(respHeaders)
if str != nil {
if respHeaders, err := str.Header(); err == nil {
handler.OnReceiveHeaders(respHeaders)
}
}

// Download each response message
Expand All @@ -288,7 +290,9 @@ func invokeServerStream(ctx context.Context, stub grpcdynamic.Stub, md *desc.Met
return fmt.Errorf("grpc call for %q failed: %v", md.GetFullyQualifiedName(), err)
}

handler.OnReceiveTrailers(stat, str.Trailer())
if str != nil {
handler.OnReceiveTrailers(stat, str.Trailer())
}

return nil
}
Expand Down

0 comments on commit d5b8e4d

Please sign in to comment.