diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2016-03-15 18:56:34 +0100 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2016-03-17 00:31:53 +0100 |
commit | 80da2ec697de3b5a5a6fc0669aa4429e51971563 (patch) | |
tree | 71998f083e893fe4a6a3474127976bbef5d06cf9 /test/core/support | |
parent | b9012fc03c91a81429ac650492dee5184d6adc47 (diff) |
Preventing huge stacks in load_file_test.
Diffstat (limited to 'test/core/support')
-rw-r--r-- | test/core/support/load_file_test.c | 14 |
1 files 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) { |