From 26d44ef5f127c9869454e6c648bdea248d26a4ac Mon Sep 17 00:00:00 2001 From: James Jackson-South Date: Sat, 6 Apr 2024 11:29:51 +1000 Subject: [PATCH] Clear pixel buffers on decode. --- .../Jpeg/Components/Decoder/SpectralConverter{TPixel}.cs | 3 ++- src/ImageSharp/Formats/Tga/TgaDecoderCore.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter{TPixel}.cs b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter{TPixel}.cs index 5add4c6f06..7f89baba58 100644 --- a/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter{TPixel}.cs +++ b/src/ImageSharp/Formats/Jpeg/Components/Decoder/SpectralConverter{TPixel}.cs @@ -201,7 +201,8 @@ public override void PrepareForDecoding() this.pixelBuffer = allocator.Allocate2D( pixelSize.Width, pixelSize.Height, - this.Configuration.PreferContiguousImageBuffers); + this.Configuration.PreferContiguousImageBuffers, + AllocationOptions.Clean); this.paddedProxyPixelRow = allocator.Allocate(pixelSize.Width + 3); // Component processors from spectral to RGB diff --git a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs index 26e057bff9..34f4c2bcf1 100644 --- a/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs +++ b/src/ImageSharp/Formats/Tga/TgaDecoderCore.cs @@ -84,7 +84,7 @@ public Image Decode(BufferedReadStream stream, CancellationToken throw new UnknownImageFormatException("Width or height cannot be 0"); } - Image image = Image.CreateUninitialized(this.configuration, this.fileHeader.Width, this.fileHeader.Height, this.metadata); + Image image = new(this.configuration, this.fileHeader.Width, this.fileHeader.Height, this.metadata); Buffer2D pixels = image.GetRootFramePixelBuffer(); if (this.fileHeader.ColorMapType == 1)