Browse Source
Merge pull request #2059 from ynse01/issue-exif-null-array-value
Fix null reference exception on Exif clone of null ExifArrayValue
pull/2065/head
Brian Popow
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
18 additions and
1 deletions
-
src/ImageSharp/Metadata/Profiles/Exif/Values/ExifValue.cs
-
tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.Metadata.cs
-
tests/ImageSharp.Tests/TestImages.cs
-
tests/Images/Input/Jpg/issues/issue-2056-exif-null-array.jpg
|
|
|
@ -29,7 +29,7 @@ namespace SixLabors.ImageSharp.Metadata.Profiles.Exif |
|
|
|
{ |
|
|
|
// All array types are value types so Clone() is sufficient here.
|
|
|
|
var array = (Array)other.GetValue(); |
|
|
|
this.TrySetValue(array.Clone()); |
|
|
|
this.TrySetValue(array?.Clone()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -302,6 +302,19 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg |
|
|
|
Assert.Null(ex); |
|
|
|
} |
|
|
|
|
|
|
|
[Theory] |
|
|
|
[WithFile(TestImages.Jpeg.Issues.ExifNullArrayTag, PixelTypes.Rgba32)] |
|
|
|
public void Clone_WithNullRationalArrayTag_DoesNotThrowException<TPixel>(TestImageProvider<TPixel> provider) |
|
|
|
where TPixel : unmanaged, IPixel<TPixel> |
|
|
|
{ |
|
|
|
Exception ex = Record.Exception(() => |
|
|
|
{ |
|
|
|
using Image<TPixel> image = provider.GetImage(JpegDecoder); |
|
|
|
var clone = image.Metadata.ExifProfile.DeepClone(); |
|
|
|
}); |
|
|
|
Assert.Null(ex); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public void EncodedStringTags_WriteAndRead() |
|
|
|
{ |
|
|
|
|
|
|
|
@ -262,6 +262,7 @@ namespace SixLabors.ImageSharp.Tests |
|
|
|
public const string MalformedUnsupportedComponentCount = "Jpg/issues/issue-1900-malformed-unsupported-255-components.jpg"; |
|
|
|
public const string MultipleApp01932 = "Jpg/issues/issue-1932-app0-resolution.jpg"; |
|
|
|
public const string InvalidIptcTag = "Jpg/issues/Issue1942InvalidIptcTag.jpg"; |
|
|
|
public const string ExifNullArrayTag = "Jpg/issues/issue-2056-exif-null-array.jpg"; |
|
|
|
|
|
|
|
public static class Fuzz |
|
|
|
{ |
|
|
|
|
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
version https://git-lfs.github.com/spec/v1 |
|
|
|
oid sha256:4c52500be37a8ea1ee1caeb78c79e44b02e10912df4f6db65313c6745573c8ee |
|
|
|
size 250451 |