Skip to content

Commit

Permalink
Fix memory leak in op_send_message
Browse files Browse the repository at this point in the history
There is no corresponding `grpc_byte_buffer_destroy` for this
`grpc_byte_buffer_copy` call in `op_send_message`, as `op`s are not recursively
`free`d.

Fix it by referring directly to the byte buffer instead of copying it, as the
byte buffer will remain alive for the lifetime of the `Op`, see
`withOpArrayAndCtxts`.

Source: awakesecurity#137
  • Loading branch information
mrBliss committed Sep 28, 2022
1 parent 7e956c0 commit f8d4dd8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/cbits/grpc_haskell.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void op_send_message(grpc_op *op_array, size_t i,
grpc_byte_buffer *payload){
grpc_op *op = op_array + i;
op->op = GRPC_OP_SEND_MESSAGE;
op->data.send_message.send_message = grpc_byte_buffer_copy(payload);
op->data.send_message.send_message = payload;
op->flags = 0;
op->reserved = NULL;
}
Expand Down

0 comments on commit f8d4dd8

Please sign in to comment.