about summary refs log tree commit diff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-03-22T12·19+0100
committerEelco Dolstra <edolstra@gmail.com>2018-03-22T12·19+0100
commitf87e286e82f37c3746ba62ba5503db90277eeb6e (patch)
tree627a0914bf495a43969a3448d0a05049a5b078ea /src/libstore/build.cc
parent92aee1b7d69adc9552dc0efae9d030e02aa2f353 (diff)
parent6b9a03f5d878ae434b54bb883b51e28082dc30b3 (diff)
Merge branch 'fix/avoid-large-stack-buffers' of https://github.com/dtzWill/nix
Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 082cd7db0f84..73139d6d551a 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -4161,10 +4161,10 @@ void Worker::waitForInput()
         assert(goal);
 
         set<int> fds2(j->fds);
+        std::vector<unsigned char> buffer(4096);
         for (auto & k : fds2) {
             if (FD_ISSET(k, &fds)) {
-                unsigned char buffer[4096];
-                ssize_t rd = read(k, buffer, sizeof(buffer));
+                ssize_t rd = read(k, buffer.data(), buffer.size());
                 if (rd == -1) {
                     if (errno != EINTR)
                         throw SysError(format("reading from %1%")
@@ -4176,7 +4176,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);
                 }