Skip to content

Commit

Permalink
fix nil slice append nil pointer failure
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <kpango@vdaas.org>
  • Loading branch information
kpango committed Jan 14, 2021
1 parent 9a39401 commit 6da7b75
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions internal/net/grpc/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ func BidirectionalStream(ctx context.Context, stream grpc.ServerStream,
errs = errors.Wrap(errs, err.Error())
gerr := status.FromError(err)
if gerr != nil {
if gerrs == nil {
gerrs = gerr
return true
}

} else if msg, ok := m.(string); ok {
hostname, err := os.Hostname()
if err != nil {
Expand All @@ -79,9 +76,17 @@ func BidirectionalStream(ctx context.Context, stream grpc.ServerStream,
Instance: hostname,
}
}
if gerr != nil {
gerrs.Roots = append(gerrs.Roots, gerr)
if gerr == nil {
return true
}
if gerrs == nil {
gerrs = gerr
return true
}
if gerrs.Roots == nil {
gerr.Roots = make([]*errors.Errors_RPC, concurrency)
}
gerrs.Roots = append(gerrs.Roots, gerr)
return true
})
st, err := status.New(status.Unknown, errs.Error()).WithDetails(gerrs)
Expand Down

0 comments on commit 6da7b75

Please sign in to comment.