diff --git a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs index 314f26d64..4f247c434 100644 --- a/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs +++ b/src/ImageSharp/Formats/Webp/Lossless/LosslessUtils.cs @@ -764,12 +764,12 @@ namespace SixLabors.ImageSharp.Formats.Webp.Lossless if (Avx2.IsSupported) { double retVal = 0.0d; - Span tmp = stackalloc int[8]; + Vector256 tmp = Vector256.Zero; // has the size of the scratch space of sizeof(int) * 8 ref int xRef = ref MemoryMarshal.GetReference(x); ref int yRef = ref MemoryMarshal.GetReference(y); Vector256 sumXY256 = Vector256.Zero; Vector256 sumX256 = Vector256.Zero; - ref int tmpRef = ref MemoryMarshal.GetReference(tmp); + ref int tmpRef = ref Unsafe.As, int>(ref tmp); for (nint i = 0; i < 256; i += 8) { Vector256 xVec = Unsafe.As>(ref Unsafe.Add(ref xRef, i));