From 3e0d936100965bd0bee53478b795a96240312110 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 15 Apr 2016 13:36:25 -0700 Subject: [PATCH] Fix loop --- test/core/end2end/fuzzers/api_fuzzer.c | 35 +++++++++++++------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 7b107d2bc3d..f9e74310da3 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -635,22 +635,23 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { } op->reserved = NULL; op->flags = read_uint32(&inp); - if (ok) { - validator *v = create_validator(decrement, &pending_ops); - pending_ops++; - grpc_call_error error = grpc_call_start_batch( - on_server ? calls[0].server : calls[0].client, ops, num_ops, - v, NULL); - if (error != GRPC_CALL_OK) { - v->validate(v->arg, false); - gpr_free(v); - } - } else { - end(&inp); + } + if (ok) { + validator *v = create_validator(decrement, &pending_ops); + pending_ops++; + grpc_call_error error = grpc_call_start_batch( + on_server ? calls[0].server : calls[0].client, ops, num_ops, + v, NULL); + if (error != GRPC_CALL_OK) { + v->validate(v->arg, false); + gpr_free(v); } - for (i = 0; i < num_ops; i++) { - op = &ops[i]; - switch (op->op) { + } else { + end(&inp); + } + for (i = 0; i < num_ops; i++) { + op = &ops[i]; + switch (op->op) { case GRPC_OP_SEND_INITIAL_METADATA: for (size_t j = 0; j < op->data.send_initial_metadata.count; j++) { gpr_free((void*)op->data.send_initial_metadata.metadata[j].key); @@ -675,10 +676,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { case GRPC_OP_RECV_STATUS_ON_CLIENT: case GRPC_OP_RECV_CLOSE_ON_SERVER: break; - } } - gpr_free(ops); } + gpr_free(ops); + break; } // cancel current call on client