aboutsummaryrefslogtreecommitdiff
path: root/src/ruby/ext/grpc/rb_channel_args.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ruby/ext/grpc/rb_channel_args.c')
-rw-r--r--src/ruby/ext/grpc/rb_channel_args.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/ruby/ext/grpc/rb_channel_args.c b/src/ruby/ext/grpc/rb_channel_args.c
index 8b7b176953..0dd43bcec9 100644
--- a/src/ruby/ext/grpc/rb_channel_args.c
+++ b/src/ruby/ext/grpc/rb_channel_args.c
@@ -71,7 +71,7 @@ static int grpc_rb_channel_create_in_process_add_args_hash_cb(VALUE key,
return ST_STOP;
}
- args->args[args->num_args - 1].key = (char*)the_key;
+ args->args[args->num_args - 1].key = gpr_strdup(the_key);
switch (TYPE(val)) {
case T_SYMBOL:
args->args[args->num_args - 1].type = GRPC_ARG_STRING;
@@ -163,6 +163,8 @@ void grpc_rb_channel_args_destroy(grpc_channel_args* args) {
GPR_ASSERT(args != NULL);
if (args->args == NULL) return;
for (int i = 0; i < args->num_args; i++) {
+ // the key was created with gpr_strdup
+ gpr_free(args->args[i].key);
if (args->args[i].type == GRPC_ARG_STRING) {
// we own string pointers, which were created with gpr_strdup
gpr_free(args->args[i].value.string);