Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Fix BMP RLE delta escape reading from wrong file position#9443

Open
bysiber wants to merge 3 commits intopython-pillow:mainfrom
bysiber:fix-bmp-rle-delta-double-read
Open

Fix BMP RLE delta escape reading from wrong file position#9443
bysiber wants to merge 3 commits intopython-pillow:mainfrom
bysiber:fix-bmp-rle-delta-double-read

Conversation

@bysiber
Copy link

The BMP RLE decoder's delta escape handler reads the displacement bytes twice from the file stream. It reads 2 bytes intobytes_read for validation, then callsself.fd.read(2) again instead of unpackingbytes_read:

bytes_read=self.fd.read(2)# read delta bytesiflen(bytes_read)<2:breakright,up=self.fd.read(2)# reads 2 MORE bytes, discards the actual delta values

The real delta displacement values are thrown away, andright /up come from whatever happens to be next in the stream. Any RLE-compressed BMP that uses delta escape codes gets decoded with wrong pixel offsets, producing corrupted output.

@radarhere
Copy link
Member

https://www.digicamsoft.com/bmp/bmp.html supports your change

2 Delta. The two bytes following the escape contain unsigned values indicating the horizontal and vertical offsets of the next pixel from the current position.

@bysiber
Copy link
Author

Thanks for confirming with the spec, glad the fix aligns with what the BMP reference says.

@radarhereradarhere mentioned this pull requestFeb 20, 2026
@radarhere
Copy link
Member

I've createdbysiber#3 to add a test.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@radarhereradarhereradarhere approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@bysiber@radarhere

[8]ページ先頭

©2009-2026 Movatter.jp