diff options
author | Craig Tiller <ctiller@google.com> | 2017-02-06 13:05:39 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-02-06 13:05:39 -0800 |
commit | 93727aaaa767db37f1f30c1eec444b44091c4959 (patch) | |
tree | f129b926726f4d264882ef31e7b8f5ceb26686b5 /src/core/lib/surface/call.c | |
parent | c4dacabb65048b763b6d3cf60f5800cf71696752 (diff) |
Fix memory leak when re-attempting send_status after it failed
Diffstat (limited to 'src/core/lib/surface/call.c')
-rw-r--r-- | src/core/lib/surface/call.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index 70bab4c079..a8152964fc 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -1483,6 +1483,7 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx, } bctl->send_final_op = 1; call->sent_final_op = 1; + GPR_ASSERT(call->send_extra_metadata_count == 0); call->send_extra_metadata_count = 1; call->send_extra_metadata[0].md = grpc_channel_get_reffed_status_elem( exec_ctx, call->channel, op->data.send_status_from_server.status); @@ -1511,6 +1512,10 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx, (int)op->data.send_status_from_server.trailing_metadata_count, op->data.send_status_from_server.trailing_metadata, 1, 1, NULL, 0)) { + for (int n = 0; n < call->send_extra_metadata_count; n++) { + GRPC_MDELEM_UNREF(exec_ctx, call->send_extra_metadata[n].md); + } + call->send_extra_metadata_count = 0; error = GRPC_CALL_ERROR_INVALID_METADATA; goto done_with_error; } |