Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't take buffer on stack, 4M may be too big.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 16 May 2019 21:14:17 +0000 (23:14 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 16 May 2019 21:21:43 +0000 (23:21 +0200)
src/smpi/internals/smpi_global.cpp

index 766a09a..66ebe69 100644 (file)
@@ -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);
 }