From c89a3d536891da84403b025c70f1ae225faa0eb2 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Thu, 1 Mar 2018 15:00:58 -0600 Subject: don't allocate large buffers on the stack --- src/libstore/build.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libstore/build.cc') diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 1d611ffba..b33649e6b 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -4156,8 +4156,8 @@ void Worker::waitForInput() set fds2(j->fds); for (auto & k : fds2) { if (FD_ISSET(k, &fds)) { - unsigned char buffer[4096]; - ssize_t rd = read(k, buffer, sizeof(buffer)); + std::vector buffer(4096); + ssize_t rd = read(k, buffer.data(), buffer.size()); if (rd == -1) { if (errno != EINTR) throw SysError(format("reading from %1%") @@ -4169,7 +4169,7 @@ void Worker::waitForInput() } else { printMsg(lvlVomit, format("%1%: read %2% bytes") % goal->getName() % rd); - string data((char *) buffer, rd); + string data((char *) buffer.data(), rd); j->lastOutput = after; goal->handleChildOutput(k, data); } -- cgit v1.2.3 From 6b9a03f5d878ae434b54bb883b51e28082dc30b3 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Thu, 1 Mar 2018 18:58:41 -0600 Subject: hoist vector out of loop just in case --- src/libstore/build.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libstore/build.cc') diff --git a/src/libstore/build.cc b/src/libstore/build.cc index b33649e6b..a1654917d 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -4154,9 +4154,9 @@ void Worker::waitForInput() assert(goal); set fds2(j->fds); + std::vector buffer(4096); for (auto & k : fds2) { if (FD_ISSET(k, &fds)) { - std::vector buffer(4096); ssize_t rd = read(k, buffer.data(), buffer.size()); if (rd == -1) { if (errno != EINTR) -- cgit v1.2.3