From 80da2ec697de3b5a5a6fc0669aa4429e51971563 Mon Sep 17 00:00:00 2001
From: "Nicolas \"Pixel\" Noble" <pixel@nobis-crew.org>
Date: Tue, 15 Mar 2016 18:56:34 +0100
Subject: [PATCH] Preventing huge stacks in load_file_test.

---
 test/core/support/load_file_test.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/test/core/support/load_file_test.c b/test/core/support/load_file_test.c
index e6ba617440..70189b739d 100644
--- a/test/core/support/load_file_test.c
+++ b/test/core/support/load_file_test.c
@@ -135,33 +135,33 @@ static void test_load_big_file(void) {
   gpr_slice slice;
   int success;
   char *tmp_name;
-  unsigned char buffer[124631];
+  static const size_t buffer_size = 124631;
+  unsigned char *buffer = gpr_malloc(buffer_size);
   unsigned char *current;
   size_t i;
 
   LOG_TEST_NAME("test_load_big_file");
 
-  for (i = 0; i < sizeof(buffer); i++) {
-    buffer[i] = 42;
-  }
+  memset(buffer, 42, buffer_size);
 
   tmp = gpr_tmpfile(prefix, &tmp_name);
   GPR_ASSERT(tmp != NULL);
   GPR_ASSERT(tmp_name != NULL);
-  GPR_ASSERT(fwrite(buffer, 1, sizeof(buffer), tmp) == sizeof(buffer));
+  GPR_ASSERT(fwrite(buffer, 1, buffer_size, tmp) == buffer_size);
   fclose(tmp);
 
   slice = gpr_load_file(tmp_name, 0, &success);
   GPR_ASSERT(success == 1);
-  GPR_ASSERT(GPR_SLICE_LENGTH(slice) == sizeof(buffer));
+  GPR_ASSERT(GPR_SLICE_LENGTH(slice) == buffer_size);
   current = GPR_SLICE_START_PTR(slice);
-  for (i = 0; i < sizeof(buffer); i++) {
+  for (i = 0; i < buffer_size; i++) {
     GPR_ASSERT(current[i] == 42);
   }
 
   remove(tmp_name);
   gpr_free(tmp_name);
   gpr_slice_unref(slice);
+  gpr_free(buffer);
 }
 
 int main(int argc, char **argv) {
-- 
GitLab