mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
LibGUI: Don't crash if calling GClipboard::set_data() with a null string.
This commit is contained in:
parent
ce7017e1ec
commit
77a782a67e
Notes:
sideshowbarker
2024-07-19 15:01:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/77a782a67ec
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");
|
||||
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();
|
||||
request.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id();
|
||||
request.clipboard.contents_size = data.length();
|
||||
|
|
Loading…
Add table
Reference in a new issue