mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 07:41:01 +00:00
LibGfx: Allow IPC encode/decode of empty BitmapSequence
This would fail with EINVAL earlier, due to an attempt to create a zero-length Core::AnonymousBuffer. We fix this by transferring the buffer length separately, and only going down the AnonymousBuffer allocation path if the length is non-zero.
This commit is contained in:
parent
6737b8b065
commit
f44166ebd0
Notes:
github-actions[bot]
2024-12-19 15:50:38 +00:00
Author: https://github.com/awesomekling
Commit: f44166ebd0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2961
Reviewed-by: https://github.com/gmta ✅
1 changed files with 21 additions and 12 deletions
|
@ -76,6 +76,9 @@ ErrorOr<void> encode(Encoder& encoder, Gfx::BitmapSequence const& bitmap_sequenc
|
||||||
|
|
||||||
TRY(encoder.encode(metadata));
|
TRY(encoder.encode(metadata));
|
||||||
|
|
||||||
|
TRY(encoder.encode(total_buffer_size));
|
||||||
|
|
||||||
|
if (total_buffer_size > 0) {
|
||||||
// collate all of the bitmap data into one contiguous buffer
|
// collate all of the bitmap data into one contiguous buffer
|
||||||
auto collated_buffer = TRY(Core::AnonymousBuffer::create_with_size(total_buffer_size));
|
auto collated_buffer = TRY(Core::AnonymousBuffer::create_with_size(total_buffer_size));
|
||||||
|
|
||||||
|
@ -90,6 +93,7 @@ ErrorOr<void> encode(Encoder& encoder, Gfx::BitmapSequence const& bitmap_sequenc
|
||||||
}
|
}
|
||||||
|
|
||||||
TRY(encoder.encode(collated_buffer));
|
TRY(encoder.encode(collated_buffer));
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -98,7 +102,12 @@ template<>
|
||||||
ErrorOr<Gfx::BitmapSequence> decode(Decoder& decoder)
|
ErrorOr<Gfx::BitmapSequence> decode(Decoder& decoder)
|
||||||
{
|
{
|
||||||
auto metadata_list = TRY(decoder.decode<Vector<Optional<Gfx::BitmapMetadata>>>());
|
auto metadata_list = TRY(decoder.decode<Vector<Optional<Gfx::BitmapMetadata>>>());
|
||||||
auto collated_buffer = TRY(decoder.decode<Core::AnonymousBuffer>());
|
|
||||||
|
auto total_buffer_size = TRY(decoder.decode<size_t>());
|
||||||
|
|
||||||
|
Core::AnonymousBuffer collated_buffer;
|
||||||
|
if (total_buffer_size > 0)
|
||||||
|
collated_buffer = TRY(decoder.decode<Core::AnonymousBuffer>());
|
||||||
|
|
||||||
Gfx::BitmapSequence result = {};
|
Gfx::BitmapSequence result = {};
|
||||||
auto& bitmaps = result.bitmaps;
|
auto& bitmaps = result.bitmaps;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue