Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4777a0b

Browse files
bysiberradarhere
andauthored
Fix BMP RLE delta escape reading from wrong file position (#9443)
Co-authored-by: Andrew Murray <[email protected]>
1 parent 02764a0 commit 4777a0b

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

Tests/images/pal8rletrns.png

3.99 KB
Loading

Tests/test_file_bmp.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@ def test_rle8_eof(file_name: str, length: int) -> None:
221221
im.load()
222222

223223

224+
def test_rle_delta() -> None:
225+
with Image.open("Tests/images/bmp/q/pal8rletrns.bmp") as im:
226+
assert_image_equal_tofile(im, "Tests/images/pal8rletrns.png")
227+
228+
224229
def test_unsupported_bmp_bitfields_layout() -> None:
225230
fp = io.BytesIO(
226231
o32(40) # header size

src/PIL/BmpImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def decode(self, buffer: bytes | Image.SupportsArrayInterface) -> tuple[int, int
369369
bytes_read = self.fd.read(2)
370370
if len(bytes_read) < 2:
371371
break
372-
right, up = self.fd.read(2)
372+
right, up = bytes_read
373373
data += b"\x00" * (right + up * self.state.xsize)
374374
x = len(data) % self.state.xsize
375375
else:

0 commit comments

Comments
 (0)