Skip to content
Snippets Groups Projects
Commit 77349cd8 authored by Alexander Polcyn's avatar Alexander Polcyn
Browse files

fix ruby memory leaks when composing credentials

parent abcdfc96
No related branches found
No related tags found
No related merge requests found
...@@ -239,6 +239,7 @@ static VALUE grpc_rb_call_credentials_compose(int argc, VALUE *argv, ...@@ -239,6 +239,7 @@ static VALUE grpc_rb_call_credentials_compose(int argc, VALUE *argv,
VALUE self) { VALUE self) {
grpc_call_credentials *creds; grpc_call_credentials *creds;
grpc_call_credentials *other; grpc_call_credentials *other;
grpc_call_credentials *prev = NULL;
VALUE mark; VALUE mark;
if (argc == 0) { if (argc == 0) {
return self; return self;
...@@ -249,6 +250,10 @@ static VALUE grpc_rb_call_credentials_compose(int argc, VALUE *argv, ...@@ -249,6 +250,10 @@ static VALUE grpc_rb_call_credentials_compose(int argc, VALUE *argv,
rb_ary_push(mark, argv[i]); rb_ary_push(mark, argv[i]);
other = grpc_rb_get_wrapped_call_credentials(argv[i]); other = grpc_rb_get_wrapped_call_credentials(argv[i]);
creds = grpc_composite_call_credentials_create(creds, other, NULL); creds = grpc_composite_call_credentials_create(creds, other, NULL);
if (prev != NULL) {
grpc_call_credentials_release(prev);
}
prev = creds;
} }
return grpc_rb_wrap_call_credentials(creds, mark); return grpc_rb_wrap_call_credentials(creds, mark);
} }
......
...@@ -184,6 +184,7 @@ static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE *argv, ...@@ -184,6 +184,7 @@ static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE *argv,
VALUE self) { VALUE self) {
grpc_channel_credentials *creds; grpc_channel_credentials *creds;
grpc_call_credentials *other; grpc_call_credentials *other;
grpc_channel_credentials *prev = NULL;
VALUE mark; VALUE mark;
if (argc == 0) { if (argc == 0) {
return self; return self;
...@@ -195,6 +196,11 @@ static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE *argv, ...@@ -195,6 +196,11 @@ static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE *argv,
rb_ary_push(mark, argv[i]); rb_ary_push(mark, argv[i]);
other = grpc_rb_get_wrapped_call_credentials(argv[i]); other = grpc_rb_get_wrapped_call_credentials(argv[i]);
creds = grpc_composite_channel_credentials_create(creds, other, NULL); creds = grpc_composite_channel_credentials_create(creds, other, NULL);
if (prev != NULL) {
grpc_channel_credentials_release(prev);
}
prev = creds;
if (creds == NULL) { if (creds == NULL) {
rb_raise(rb_eRuntimeError, rb_raise(rb_eRuntimeError,
"Failed to compose channel and call credentials"); "Failed to compose channel and call credentials");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment