From 7ea8408e0d6cf79c4cf497ab2e485ab41dd2e3ec Mon Sep 17 00:00:00 2001 From: Jason Nelson Date: Tue, 17 Apr 2018 12:45:58 -0700 Subject: [PATCH] Fix offset when copying to buffer --- src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs index 1d195f597..40674ddf1 100644 --- a/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs +++ b/src/ImageSharp/Formats/Bmp/BmpDecoderCore.cs @@ -285,12 +285,14 @@ namespace SixLabors.ImageSharp.Formats.Bmp byte[] run = new byte[length]; - this.stream.Read(run, 0, length); + this.stream.Read(run, 0, run.Length); - run.AsSpan().CopyTo(buffer); + run.AsSpan().CopyTo(buffer.Slice(count)); + + count += run.Length; // Absolute mode data is aligned to two-byte word-boundary - int padding = length & 0; + int padding = length & 1; this.stream.Skip(padding);