LibGfx: Prevent potential heap-overflow in BMP non-RLE

This commit is contained in:
Ben Wiederhake 2020-12-01 22:22:20 +01:00 committed by Andreas Kling
commit 6be9b6349d
Notes: sideshowbarker 2024-07-19 01:06:38 +09:00

View file

@ -1200,7 +1200,7 @@ static bool decode_bmp_pixel_data(BMPLoadingContext& context)
return false;
}
auto buffer = ByteBuffer::wrap(const_cast<u8*>(context.file_bytes + context.data_offset), context.file_size);
auto buffer = ByteBuffer::wrap(const_cast<u8*>(context.file_bytes + context.data_offset), context.file_size - context.data_offset);
if (context.dib.info.compression == Compression::RLE4 || context.dib.info.compression == Compression::RLE8
|| context.dib.info.compression == Compression::RLE24) {