diff options
author | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2016-05-22 17:32:07 -0400 |
---|---|---|
committer | Jan Tattermusch <jtattermusch@users.noreply.github.com> | 2016-05-22 17:32:07 -0400 |
commit | 336292d2f38b9883e2002f1f1c89704b971d62a6 (patch) | |
tree | 3b7dbd60c11dd0fefb7881a51e50b1a3ae036f76 /test | |
parent | b6c7a5ae5fd300359a21e2d454df75b4578b5f60 (diff) | |
parent | 93dd0470cf26aed445b40a8b9332e6b06f5e5514 (diff) |
Merge pull request #6423 from ctiller/signal_handler
Fix some ubsan issues
Diffstat (limited to 'test')
-rw-r--r-- | test/core/end2end/fuzzers/api_fuzzer.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index cdfa960623..a8b123257f 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -424,15 +424,19 @@ static void add_to_free(call_state *call, void *p) { static void read_metadata(input_stream *inp, size_t *count, grpc_metadata **metadata, call_state *cs) { *count = next_byte(inp); - *metadata = gpr_malloc(*count * sizeof(**metadata)); - memset(*metadata, 0, *count * sizeof(**metadata)); - for (size_t i = 0; i < *count; i++) { - (*metadata)[i].key = read_string(inp); - read_buffer(inp, (char **)&(*metadata)[i].value, - &(*metadata)[i].value_length); - (*metadata)[i].flags = read_uint32(inp); - add_to_free(cs, (void *)(*metadata)[i].key); - add_to_free(cs, (void *)(*metadata)[i].value); + if (*count) { + *metadata = gpr_malloc(*count * sizeof(**metadata)); + memset(*metadata, 0, *count * sizeof(**metadata)); + for (size_t i = 0; i < *count; i++) { + (*metadata)[i].key = read_string(inp); + read_buffer(inp, (char **)&(*metadata)[i].value, + &(*metadata)[i].value_length); + (*metadata)[i].flags = read_uint32(inp); + add_to_free(cs, (void *)(*metadata)[i].key); + add_to_free(cs, (void *)(*metadata)[i].value); + } + } else { + *metadata = gpr_malloc(1); } add_to_free(cs, *metadata); } |