diff options
author | Craig Tiller <ctiller@google.com> | 2016-05-22 15:24:21 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-05-22 15:24:21 -0700 |
commit | 22cfb658464526d15b6b2ae603b798adf1941895 (patch) | |
tree | 28142174a3d12b44075e0312ea641e2372864a59 /src/core/ext/client_config | |
parent | 62a0b5941b413a88e3589ec4b0191f6eb55e3b11 (diff) | |
parent | 336292d2f38b9883e2002f1f1c89704b971d62a6 (diff) |
Merge github.com:grpc/grpc into error
Diffstat (limited to 'src/core/ext/client_config')
-rw-r--r-- | src/core/ext/client_config/subchannel.c | 2 | ||||
-rw-r--r-- | src/core/ext/client_config/subchannel_index.c | 29 |
2 files changed, 21 insertions, 10 deletions
diff --git a/src/core/ext/client_config/subchannel.c b/src/core/ext/client_config/subchannel.c index 0c175cd6c7..dd61caea94 100644 --- a/src/core/ext/client_config/subchannel.c +++ b/src/core/ext/client_config/subchannel.c @@ -320,7 +320,7 @@ grpc_subchannel *grpc_subchannel_create(grpc_exec_ctx *exec_ctx, c->filters = NULL; } c->addr = gpr_malloc(args->addr_len); - memcpy(c->addr, args->addr, args->addr_len); + if (args->addr_len) memcpy(c->addr, args->addr, args->addr_len); c->pollset_set = grpc_pollset_set_create(); c->addr_len = args->addr_len; grpc_set_initial_connect_string(&c->addr, &c->addr_len, diff --git a/src/core/ext/client_config/subchannel_index.c b/src/core/ext/client_config/subchannel_index.c index ab8d9bd91d..690cb16b96 100644 --- a/src/core/ext/client_config/subchannel_index.c +++ b/src/core/ext/client_config/subchannel_index.c @@ -77,12 +77,19 @@ static grpc_subchannel_key *create_key( grpc_subchannel_key *k = gpr_malloc(sizeof(*k)); k->connector = grpc_connector_ref(connector); k->args.filter_count = args->filter_count; - k->args.filters = gpr_malloc(sizeof(*k->args.filters) * k->args.filter_count); - memcpy((grpc_channel_filter *)k->args.filters, args->filters, - sizeof(*k->args.filters) * k->args.filter_count); + if (k->args.filter_count > 0) { + k->args.filters = + gpr_malloc(sizeof(*k->args.filters) * k->args.filter_count); + memcpy((grpc_channel_filter *)k->args.filters, args->filters, + sizeof(*k->args.filters) * k->args.filter_count); + } else { + k->args.filters = NULL; + } k->args.addr_len = args->addr_len; k->args.addr = gpr_malloc(args->addr_len); - memcpy(k->args.addr, args->addr, k->args.addr_len); + if (k->args.addr_len > 0) { + memcpy(k->args.addr, args->addr, k->args.addr_len); + } k->args.args = copy_channel_args(args->args); return k; } @@ -104,11 +111,15 @@ static int subchannel_key_compare(grpc_subchannel_key *a, if (c != 0) return c; c = GPR_ICMP(a->args.filter_count, b->args.filter_count); if (c != 0) return c; - c = memcmp(a->args.addr, b->args.addr, a->args.addr_len); - if (c != 0) return c; - c = memcmp(a->args.filters, b->args.filters, - a->args.filter_count * sizeof(*a->args.filters)); - if (c != 0) return c; + if (a->args.addr_len) { + c = memcmp(a->args.addr, b->args.addr, a->args.addr_len); + if (c != 0) return c; + } + if (a->args.filter_count > 0) { + c = memcmp(a->args.filters, b->args.filters, + a->args.filter_count * sizeof(*a->args.filters)); + if (c != 0) return c; + } return grpc_channel_args_compare(a->args.args, b->args.args); } |