LibGfx: Accept BMP RLE of 255 repeated bytes

Previously, in the case of RLE4, parsing took suspiciously long.
What happened was that 'pixel_count' was 255, and 'i' was incremented
by *two* in each iteration, so the for-loop continued until the
entire output buffer was full, and then rejected the RLE data
as bogus.

This little diff allows pixel_count to reach 256, be greater than
pixel_count, and thus terminate the loop in the intended way.
This commit is contained in:
Ben Wiederhake 2020-12-02 20:13:29 +01:00 committed by Andreas Kling
parent 21977a2188
commit aec8983819
Notes: sideshowbarker 2024-07-19 01:05:23 +09:00

View file

@ -1059,7 +1059,7 @@ static bool uncompress_bmp_rle_data(BMPLoadingContext& context, ByteBuffer& buff
if (!result.has_value())
return false;
byte = result.value();
for (u8 i = 0; i < pixel_count; ++i) {
for (u16 i = 0; i < pixel_count; ++i) {
if (compression != Compression::RLE4) {
if (!set_byte(byte, true))
return false;