Open wkirschenmann opened 3 months ago
When passing an empty string as the module name, a NullReferenceException is thrown at System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount) in System.Text\UTF8Encoding.cs:line 433
NullReferenceException
System.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount)
This comes from the following code
[MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe int GetBytes(this Encoding encoding, string chars, Span<byte> bytes) { fixed (char* charsPtr = chars) fixed (byte* bytesPtr = bytes) { return encoding.GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length); } }
at Wasmtime.Extensions.GetBytes(Encoding encoding, String chars, Span<byte> bytes) in Wasmtime\Extensions.cs
Wasmtime.Extensions.GetBytes(Encoding encoding, String chars, Span<byte> bytes)
I'd suggest adding the following at the beginning of the GetBytes functions:
GetBytes
if (chars.Length == 0 && bytes.Length == 0) return 0;
When passing an empty string as the module name, a
NullReferenceException
is thrown atSystem.Text.UTF8Encoding.GetBytes(Char* chars, Int32 charCount, Byte* bytes, Int32 byteCount)
in System.Text\UTF8Encoding.cs:line 433This comes from the following code
at
Wasmtime.Extensions.GetBytes(Encoding encoding, String chars, Span<byte> bytes)
in Wasmtime\Extensions.csI'd suggest adding the following at the beginning of the
GetBytes
functions: