1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

ProtocolServer: did_finish_download: Do not create 0 byte shared buffer

`PSClientConnection::did_finish_download()` no longer tries to create
a zero byte shared buffer when `download.payload().data()` is zero
bytes in length.

Fixes #1821
This commit is contained in:
Brendan Coles 2020-04-17 00:46:50 +00:00 committed by Andreas Kling
parent d5fb916bf0
commit 0a483cf677

View file

@ -79,7 +79,7 @@ OwnPtr<Messages::ProtocolServer::StopDownloadResponse> PSClientConnection::handl
void PSClientConnection::did_finish_download(Badge<Download>, Download& download, bool success) void PSClientConnection::did_finish_download(Badge<Download>, Download& download, bool success)
{ {
RefPtr<SharedBuffer> buffer; RefPtr<SharedBuffer> buffer;
if (success && !download.payload().is_null()) { if (success && download.payload().size() > 0 && !download.payload().is_null()) {
buffer = SharedBuffer::create_with_size(download.payload().size()); buffer = SharedBuffer::create_with_size(download.payload().size());
memcpy(buffer->data(), download.payload().data(), download.payload().size()); memcpy(buffer->data(), download.payload().data(), download.payload().size());
buffer->seal(); buffer->seal();