1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-02 21:51:50 +02:00

don't allocate large buffers on the stack

This commit is contained in:
Will Dietz 2018-03-01 15:00:58 -06:00
parent 3748a0ca1e
commit c89a3d5368
5 changed files with 30 additions and 29 deletions

View file

@ -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);
}