mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:28:10 +00:00
LibGUI: Fix OOB read in Clipboard::set_data()
This commit is contained in:
parent
125ea6a214
commit
02f251bb4a
1 changed files with 2 additions and 4 deletions
|
@ -98,15 +98,13 @@ Clipboard::DataAndType Clipboard::data_and_type() const
|
|||
|
||||
void Clipboard::set_data(ReadonlyBytes data, const String& type, const HashMap<String, String>& metadata)
|
||||
{
|
||||
auto shared_buffer = SharedBuffer::create_with_size(data.size() + 1);
|
||||
auto shared_buffer = SharedBuffer::create_with_size(data.size());
|
||||
if (!shared_buffer) {
|
||||
dbgprintf("GUI::Clipboard::set_data() failed to create a shared buffer\n");
|
||||
return;
|
||||
}
|
||||
if (!data.is_empty())
|
||||
memcpy(shared_buffer->data(), data.data(), data.size() + 1);
|
||||
else
|
||||
((u8*)shared_buffer->data())[0] = '\0';
|
||||
memcpy(shared_buffer->data(), data.data(), data.size());
|
||||
shared_buffer->seal();
|
||||
shared_buffer->share_with(connection().server_pid());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue