From 886bee972405bf54fe5c1dcb3f3168d5144c43cc 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 1d195f597a..40674ddf1c 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);