1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:37:35 +00:00

LibGfx: Fix serializing Gfx::Bitmaps

a396bb0 removed the palette field but did not update the allocation size
in `Bitmap::serialize_to_byte_buffer()`. This led to a few crashes (I
noticed this from a drag/drop crash in the file manager).

Fixes #21434
This commit is contained in:
MacDue 2023-10-15 19:25:35 +01:00 committed by Andreas Kling
parent f0cd7adaf8
commit 95bf6ddb8e
2 changed files with 10 additions and 1 deletions

View file

@ -126,3 +126,12 @@ TEST_CASE(0008_bitmap_downscaling_height1)
}
}
}
TEST_CASE(0009_serialize_and_deserialize_roundtrip)
{
auto original_bitmap = MUST(Gfx::Bitmap::create(Gfx::BitmapFormat::BGRx8888, Gfx::IntSize { 10, 10 }));
original_bitmap->fill(Gfx::Color::Red);
auto bytes = MUST(original_bitmap->serialize_to_byte_buffer());
auto bitmap = MUST(Gfx::Bitmap::create_from_serialized_bytes(bytes));
EXPECT(bitmap->visually_equals(original_bitmap));
}