diff options
Diffstat (limited to 'src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs')
-rw-r--r-- | src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs b/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs index 25735d5262..dc9f62fdab 100644 --- a/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs +++ b/src/csharp/Grpc.Core/Internal/MetadataArraySafeHandle.cs @@ -50,6 +50,11 @@ namespace Grpc.Core.Internal { using (Profilers.ForCurrentThread().NewScope("MetadataArraySafeHandle.Create")) { + if (metadata.Count == 0) + { + return new MetadataArraySafeHandle(); + } + // TODO(jtattermusch): we might wanna check that the metadata is readonly var metadataArray = Native.grpcsharp_metadata_array_create(new UIntPtr((ulong)metadata.Count)); for (int i = 0; i < metadata.Count; i++) |