summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--netfs/daemon/daemonFile.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/netfs/daemon/daemonFile.cpp b/netfs/daemon/daemonFile.cpp
index fb146a4..cf34b7d 100644
--- a/netfs/daemon/daemonFile.cpp
+++ b/netfs/daemon/daemonFile.cpp
@@ -44,14 +44,16 @@ NetFS::Buffer
FileServer::read(Ice::Long offset, Ice::Long size, const Ice::Current &)
{
NetFS::Buffer buf;
- buf.resize(safe {size});
- errno = 0;
- auto r = pread(fd, &buf[0], safe {size}, offset);
- if (r == -1) {
- throw NetFS::SystemError(errno);
- }
- else if (std::cmp_not_equal(r, size)) {
- buf.resize(safe {r});
+ if (size) {
+ buf.resize(safe {size});
+ errno = 0;
+ auto r = pread(fd, buf.data(), safe {size}, offset);
+ if (r == -1) {
+ throw NetFS::SystemError(errno);
+ }
+ else if (std::cmp_not_equal(r, size)) {
+ buf.resize(safe {r});
+ }
}
return buf;
}