diff options
Diffstat (limited to 'src/csharp/Grpc.Core/Internal/MarshalUtils.cs')
-rw-r--r-- | src/csharp/Grpc.Core/Internal/MarshalUtils.cs | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/csharp/Grpc.Core/Internal/MarshalUtils.cs b/src/csharp/Grpc.Core/Internal/MarshalUtils.cs index 73b7a2ef95..09ded1a036 100644 --- a/src/csharp/Grpc.Core/Internal/MarshalUtils.cs +++ b/src/csharp/Grpc.Core/Internal/MarshalUtils.cs @@ -36,8 +36,12 @@ namespace Grpc.Core.Internal public static string PtrToStringUTF8(IntPtr ptr, int len) { if (len == 0) + { return ""; + } + // TODO(jtattermusch): once Span dependency is added, + // use Span-based API to decode the string without copying the buffer. var bytes = new byte[len]; Marshal.Copy(ptr, bytes, 0, len); return EncodingUTF8.GetString(bytes); |