diff options
author | Ben Wiederhake <BenWiederhake.GitHub@gmx.de> | 2020-12-02 20:13:29 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-02 22:51:05 +0100 |
commit | aec8983819fa0cd23ce251f91305a8c2cb4450dc (patch) | |
tree | a6d541c41ef9e11bfeba54b59ba60ad4dcb9a458 /Libraries/LibGfx | |
parent | 21977a218848a7b9c76311450a12cd7224378c37 (diff) | |
download | serenity-aec8983819fa0cd23ce251f91305a8c2cb4450dc.zip |
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.
Diffstat (limited to 'Libraries/LibGfx')
-rw-r--r-- | Libraries/LibGfx/BMPLoader.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Libraries/LibGfx/BMPLoader.cpp b/Libraries/LibGfx/BMPLoader.cpp index 824203f9be..84d7d32ea6 100644 --- a/Libraries/LibGfx/BMPLoader.cpp +++ b/Libraries/LibGfx/BMPLoader.cpp @@ -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; |