I received a bad alloc when uploading a large file with CTest. The patch
below resolved this.



---
 Source/cmCTest.cxx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 2bf7b77..52bf651 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1688,7 +1688,7 @@ std::string cmCTest::Base64GzipEncodeFile(std::string
file)
 //----------------------------------------------------------------------
 std::string cmCTest::Base64EncodeFile(std::string file)
 {
-  long len = cmSystemTools::FileLength(file);
+  std::size_t len =
static_cast<std::size_t>(cmSystemTools::FileLength(file));
   cmsys::ifstream ifs(file.c_str(), std::ios::in
 #ifdef _WIN32
     | std::ios::binary
@@ -1699,7 +1699,7 @@ std::string cmCTest::Base64EncodeFile(std::string
file)
   ifs.close();

   unsigned char *encoded_buffer
-    = new unsigned char [ static_cast<int>(
+    = new unsigned char [ static_cast<std::size_t>(
         static_cast<double>(len) * 1.5 + 5.0) ];

   unsigned long rlen
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to