You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rpc_util.go
+16-6Lines changed: 16 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -961,24 +961,32 @@ func recvAndDecompress(p *parser, s recvCompressor, dc Decompressor, maxReceiveM
961
961
returnout, nil
962
962
}
963
963
964
-
// decompress processes the given data by decompressing it using either a custom decompressor or a standard compressor.
965
-
// If a custom decompressor is provided, it takes precedence. The function validates that the decompressed data
966
-
// does not exceed the specified maximum size and returns an error if this limit is exceeded.
967
-
// On success, it returns the decompressed data. Otherwise, it returns an error if decompression fails or the data exceeds the size limit.
964
+
// decompress processes the given data by decompressing it using either
965
+
// a custom decompressor or a standard compressor. If a custom decompressor
966
+
// is provided, it takes precedence. The function validates that
967
+
// the decompressed data does not exceed the specified maximum size and returns
968
+
// an error if this limit is exceeded. On success, it returns the decompressed
969
+
// data. Otherwise, it returns an error if decompression fails or the data
970
+
// exceeds the size limit.
968
971
funcdecompress(compressor encoding.Compressor, d mem.BufferSlice, dcDecompressor, maxReceiveMessageSizeint, pool mem.BufferPool) (mem.BufferSlice, error) {
969
972
ifdc!=nil {
970
-
uncompressed, err:=dc.Do(d.Reader())
973
+
r:=d.Reader()
974
+
uncompressed, err:=dc.Do(r)
971
975
iferr!=nil {
976
+
r.Close() // ensure buffers are reused
972
977
returnnil, status.Errorf(codes.Internal, "grpc: failed to decompress the received message: %v", err)
973
978
}
974
979
iflen(uncompressed) >maxReceiveMessageSize {
980
+
r.Close() // ensure buffers are reused
975
981
returnnil, status.Errorf(codes.ResourceExhausted, "grpc: message after decompression larger than max (%d vs. %d)", len(uncompressed), maxReceiveMessageSize)
0 commit comments