http2_client: fix reader segfault on PROTOCOL_ERRORs (#3926)
diff --git a/internal/transport/http2_client.go b/internal/transport/http2_client.go
index a12d6b8..e73b77a 100644
--- a/internal/transport/http2_client.go
+++ b/internal/transport/http2_client.go
@@ -1306,7 +1306,13 @@
if s != nil {
// use error detail to provide better err message
code := http2ErrConvTab[se.Code]
- msg := t.framer.fr.ErrorDetail().Error()
+ errorDetail := t.framer.fr.ErrorDetail()
+ var msg string
+ if errorDetail != nil {
+ msg = errorDetail.Error()
+ } else {
+ msg = "received invalid frame"
+ }
t.closeStream(s, status.Error(code, msg), true, http2.ErrCodeProtocol, status.New(code, msg), nil, false)
}
continue