From 77515fead23dc135ec572a302b0b864adda9a09e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 19 Dec 2020 13:05:48 +0100 Subject: [PATCH] LibGfx: Remove use of ByteBuffer::wrap() in BMP decoder --- Libraries/LibGfx/BMPLoader.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Libraries/LibGfx/BMPLoader.cpp b/Libraries/LibGfx/BMPLoader.cpp index 84d7d32ea6..218c06cee5 100644 --- a/Libraries/LibGfx/BMPLoader.cpp +++ b/Libraries/LibGfx/BMPLoader.cpp @@ -1187,15 +1187,17 @@ static bool decode_bmp_pixel_data(BMPLoadingContext& context) return false; } - auto buffer = ByteBuffer::wrap(const_cast(context.file_bytes + context.data_offset), context.file_size - context.data_offset); + ByteBuffer rle_buffer; + ReadonlyBytes bytes { 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) { - if (!uncompress_bmp_rle_data(context, buffer)) + if (!uncompress_bmp_rle_data(context, rle_buffer)) return false; + bytes = rle_buffer.bytes(); } - Streamer streamer(buffer.data(), buffer.size()); + Streamer streamer(bytes.data(), bytes.size()); auto process_row = [&](u32 row) -> bool { u32 space_remaining_before_consuming_row = streamer.remaining();