mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:38:11 +00:00
LibGUI: Don't crash if calling GClipboard::set_data() with a null string.
This commit is contained in:
parent
ce7017e1ec
commit
77a782a67e
1 changed files with 4 additions and 1 deletions
|
@ -43,7 +43,10 @@ void GClipboard::set_data(const String& data)
|
||||||
dbgprintf("GClipboard::set_data() failed to create a shared buffer\n");
|
dbgprintf("GClipboard::set_data() failed to create a shared buffer\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(shared_buffer->data(), data.characters(), data.length() + 1);
|
if (!data.is_empty())
|
||||||
|
memcpy(shared_buffer->data(), data.characters(), data.length() + 1);
|
||||||
|
else
|
||||||
|
((byte*)shared_buffer->data())[0] = '\0';
|
||||||
shared_buffer->seal();
|
shared_buffer->seal();
|
||||||
request.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id();
|
request.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id();
|
||||||
request.clipboard.contents_size = data.length();
|
request.clipboard.contents_size = data.length();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue