aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLulu <lulu.berlin.2023@gmail.com>2024-10-08 01:41:41 +0000
committerGerrit Code Review <gerrit@localhost>2024-10-08 01:41:41 +0000
commit299813f324c9562b0bd6d0bc5d2114776e193d86 (patch)
treee33dfe4834e04c8f996aac0e859422ffb5b3a70d /src
parentd6e1b11d3e91abc4194744310f36e37a57dd6e1d (diff)
parent51a5025913cd2c901203e1a8d8f8a0df1c1a130b (diff)
Merge "Avoid calling memcpy when len == 0 in filetransfer.cc" into main
Diffstat (limited to 'src')
-rw-r--r--src/libstore/filetransfer.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libstore/filetransfer.cc b/src/libstore/filetransfer.cc
index 6fe1f9a05..34b92148e 100644
--- a/src/libstore/filetransfer.cc
+++ b/src/libstore/filetransfer.cc
@@ -6,6 +6,7 @@
#include "signals.hh"
#include "compression.hh"
#include "strings.hh"
+#include <cstddef>
#if ENABLE_S3
#include <aws/core/client/ClientConfiguration.h>
@@ -784,8 +785,10 @@ struct curlFileTransfer : public FileTransfer
size_t read(char * data, size_t len) override
{
- auto readPartial = [this](char * data, size_t len) {
+ auto readPartial = [this](char * data, size_t len) -> size_t {
const auto available = std::min(len, buffered.size());
+ if (available == 0u) return 0u;
+
memcpy(data, buffered.data(), available);
buffered.remove_prefix(available);
return available;