From 84f572aa4918596fcc2ec10c0f8b9369d29467c6 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Mon, 8 Nov 2010 08:50:30 +0000 Subject: [PATCH] don't allocate too much memory on the stack in web seed test --- test/test_web_seed.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/test_web_seed.cpp b/test/test_web_seed.cpp index 47e06bcb0..c84ccb2a1 100644 --- a/test/test_web_seed.cpp +++ b/test/test_web_seed.cpp @@ -202,24 +202,26 @@ int run_suite(char const* protocol, bool test_url_seed, bool chunked_encoding) { 5, 16 - 5, 16, 17, 10, 30, 30, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 ,1,1,1,1,1,1,13,65,34,75,2,3,4,5,23,9,43,4,43,6, 4}; - char random_data[300000]; + char* random_data = (char*)malloc(300000); for (int i = 0; i != sizeof(file_sizes)/sizeof(file_sizes[0]); ++i) { - std::generate(random_data, random_data + sizeof(random_data), &std::rand); + std::generate(random_data, random_data + 300000, &std::rand); char filename[200]; snprintf(filename, sizeof(filename), "./tmp1_web_seed/test_torrent_dir/test%d", i); save_file(filename, random_data, file_sizes[i]); } add_files(fs, "./tmp1_web_seed/test_torrent_dir"); + free(random_data); } else { piece_size = 64 * 1024; - char random_data[64 * 1024 * 25]; - std::generate(random_data, random_data + sizeof(random_data), &std::rand); - save_file("./tmp1_web_seed/seed", random_data, sizeof(random_data)); - fs.add_file("seed", sizeof(random_data)); + char* random_data = (char*)malloc(64 * 1024 * 25); + std::generate(random_data, random_data + 64 * 1024 * 25, &std::rand); + save_file("./tmp1_web_seed/seed", random_data, 64 * 1024 * 25); + fs.add_file("seed", 64 * 1024 * 25); + free(random_data); } int port = start_web_server(strcmp(protocol, "https") == 0, chunked_encoding);