Browse Source

Fixed string exif value corner case null ref exception

pull/2088/head
Dmitry Pentin 4 years ago
parent
commit
c7f9d54705
  1. 12
      src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs

12
src/ImageSharp/Metadata/Profiles/Exif/ExifEncodedStringHelpers.cs

@ -79,16 +79,8 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif
return CharacterCodeBytesLength + count; return CharacterCodeBytesLength + count;
} }
public static unsafe int Write(Encoding encoding, string value, Span<byte> destination) public static unsafe int Write(Encoding encoding, string value, Span<byte> destination) =>
{ encoding.GetBytes(value.AsSpan(), destination);
fixed (char* c = value)
{
fixed (byte* b = destination)
{
return encoding.GetBytes(c, value.Length, b, destination.Length);
}
}
}
private static bool TryDetect(ReadOnlySpan<byte> buffer, out CharacterCode code) private static bool TryDetect(ReadOnlySpan<byte> buffer, out CharacterCode code)
{ {

Loading…
Cancel
Save