From: Arnaud Giersch Date: Thu, 16 May 2019 21:14:17 +0000 (+0200) Subject: Don't take buffer on stack, 4M may be too big. X-Git-Tag: v3.22.4~122^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/0284ed47bfa6a30d06972491fe2f03c53721c18f Don't take buffer on stack, 4M may be too big. --- diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index 766a09adae..66ebe69144 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -507,7 +507,7 @@ static void smpi_copy_file(const std::string& src, const std::string& target, of #endif // If this point is reached, sendfile() actually is not available. Copy file by hand. const int bufsize = 1024 * 1024 * 4; - char buf[bufsize]; + char* buf = new char[bufsize]; while (int got = read(fdin, buf, bufsize)) { if (got == -1) { xbt_assert(errno == EINTR, "Cannot read from %s", src.c_str()); @@ -524,6 +524,7 @@ static void smpi_copy_file(const std::string& src, const std::string& target, of } } } + delete[] buf; close(fdin); close(fdout); }