summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-01-16 10:58:02 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-16 11:26:53 +0100
commit7c1df68be314793fd915d63d930f81351d723f0b (patch)
tree58f677e06af19b9db44696d300b6afd4412615df
parent64610ca80ea02e6f44e52744d9b10d612b1b3da1 (diff)
downloadserenity-7c1df68be314793fd915d63d930f81351d723f0b.zip
LibGfx: Don't encode invalid Gfx::ShareableBitmap as IPC::File
IPC::File should only be used when there's an actual file to pass. Invalid ShareableBitmaps don't have a backing file, so fix this by first encoding a "valid" flag.
-rw-r--r--Userland/Libraries/LibGfx/ShareableBitmap.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/ShareableBitmap.cpp b/Userland/Libraries/LibGfx/ShareableBitmap.cpp
index 6cfa44a4b0..c3468445fc 100644
--- a/Userland/Libraries/LibGfx/ShareableBitmap.cpp
+++ b/Userland/Libraries/LibGfx/ShareableBitmap.cpp
@@ -44,6 +44,9 @@ namespace IPC {
bool encode(Encoder& encoder, const Gfx::ShareableBitmap& shareable_bitmap)
{
+ encoder << shareable_bitmap.is_valid();
+ if (!shareable_bitmap.is_valid())
+ return true;
encoder << IPC::File(shareable_bitmap.anon_fd());
encoder << shareable_bitmap.width();
encoder << shareable_bitmap.height();
@@ -52,6 +55,13 @@ bool encode(Encoder& encoder, const Gfx::ShareableBitmap& shareable_bitmap)
bool decode(Decoder& decoder, Gfx::ShareableBitmap& shareable_bitmap)
{
+ bool valid = false;
+ if (!decoder.decode(valid))
+ return false;
+ if (!valid) {
+ shareable_bitmap = {};
+ return true;
+ }
IPC::File anon_file;
Gfx::IntSize size;
if (!decoder.decode(anon_file))