From 38b24c992a2ccf2ae22f43670b126ad6548fd05d Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Mon, 2 Apr 2018 13:00:17 -0700 Subject: [PATCH] Change InvalidTags to ReadOnlyList & pin pointer. --- src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs index 05d6819b5..c00eec601 100644 --- a/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs +++ b/src/ImageSharp/MetaData/Profiles/Exif/ExifReader.cs @@ -6,7 +6,6 @@ using System.Buffers.Binary; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using SixLabors.ImageSharp.IO; @@ -39,7 +38,7 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif /// /// Gets the invalid tags. /// - public IList InvalidTags => this.invalidTags; + public IReadOnlyList InvalidTags => this.invalidTags; /// /// Gets the thumbnail length in the byte stream @@ -147,9 +146,12 @@ namespace SixLabors.ImageSharp.MetaData.Profiles.Exif string result = Encoding.UTF8.GetString(bytes, 0, buffer.Length); #else - byte* pointer = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(buffer)); + string result; - string result = Encoding.UTF8.GetString(pointer, buffer.Length); + fixed (byte* pointer = &MemoryMarshal.GetReference(buffer)) + { + result = Encoding.UTF8.GetString(pointer, buffer.Length); + } #endif int nullCharIndex = result.IndexOf('\0'); if (nullCharIndex != -1)