diff options
author | Craig Tiller <ctiller@google.com> | 2016-04-05 20:17:38 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-04-05 20:17:38 -0700 |
commit | 16c13451f0f686faadda0e13bf3d5ee7f076430b (patch) | |
tree | 78d1e4bd1bf60192c5db5736b085ee0ff4bfe1b9 | |
parent | 0b541630192d676169b785488fc08c0e863fff62 (diff) |
Fix init ordering,memory leaks
-rw-r--r-- | src/core/ext/client_config/client_config_plugin.c | 8 | ||||
-rw-r--r-- | src/core/lib/channel/channel_stack_builder.c | 2 | ||||
-rw-r--r-- | src/core/lib/surface/init.c | 2 |
3 files changed, 8 insertions, 4 deletions
diff --git a/src/core/ext/client_config/client_config_plugin.c b/src/core/ext/client_config/client_config_plugin.c index aac57b5e6a..6cd8a2ffd2 100644 --- a/src/core/ext/client_config/client_config_plugin.c +++ b/src/core/ext/client_config/client_config_plugin.c @@ -35,6 +35,8 @@ #include <stdbool.h> #include <string.h> +#include <grpc/support/alloc.h> + #include "src/core/ext/client_config/client_channel.h" #include "src/core/ext/client_config/lb_policy_registry.h" #include "src/core/ext/client_config/resolver_registry.h" @@ -64,8 +66,10 @@ static bool set_default_host_if_unset(grpc_channel_stack_builder *builder, arg.key = GRPC_ARG_DEFAULT_AUTHORITY; arg.value.string = grpc_get_default_authority( grpc_channel_stack_builder_get_target(builder)); - grpc_channel_stack_builder_set_channel_arguments( - builder, grpc_channel_args_copy_and_add(args, &arg, 1)); + grpc_channel_args *new_args = grpc_channel_args_copy_and_add(args, &arg, 1); + grpc_channel_stack_builder_set_channel_arguments(builder, new_args); + gpr_free(arg.value.string); + grpc_channel_args_destroy(new_args); return true; } diff --git a/src/core/lib/channel/channel_stack_builder.c b/src/core/lib/channel/channel_stack_builder.c index 831736ad7a..a8646c9565 100644 --- a/src/core/lib/channel/channel_stack_builder.c +++ b/src/core/lib/channel/channel_stack_builder.c @@ -142,7 +142,7 @@ void grpc_channel_stack_builder_set_channel_arguments( if (builder->args != NULL) { grpc_channel_args_destroy(builder->args); } - builder->args = grpc_channel_args_copy(builder->args); + builder->args = grpc_channel_args_copy(args); } void grpc_channel_stack_builder_set_transport( diff --git a/src/core/lib/surface/init.c b/src/core/lib/surface/init.c index 06c5dd4a31..1190adaaa6 100644 --- a/src/core/lib/surface/init.c +++ b/src/core/lib/surface/init.c @@ -126,7 +126,7 @@ static void register_builtin_channel_init() { GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, append_filter, (void *)&grpc_lame_filter); grpc_channel_init_register_stage( - GRPC_SERVER_CHANNEL, GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, prepend_filter, + GRPC_SERVER_CHANNEL, INT_MAX, prepend_filter, (void *)&grpc_server_top_filter); } |