about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorWill Dietz <w@wdtz.org>2018-03-01T21·00-0600
committerWill Dietz <w@wdtz.org>2018-03-02T16·52-0600
commitc89a3d536891da84403b025c70f1ae225faa0eb2 (patch)
treec019b3b8ead8a0c609d9a54db70e27904811863e /src/libstore
parent3748a0ca1e9406ff4a701b4f0e1f506c008c4137 (diff)
don't allocate large buffers on the stack
Diffstat (limited to 'src/libstore')
-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 1d611ffbaba5..b33649e6b4a5 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -4156,8 +4156,8 @@ void Worker::waitForInput()
         set<int> 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<unsigned char> 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);
                 }