Fix use-after-free bug.

pull/8049/head
Mark D. Roth 8 years ago
parent 90f49f58a5
commit 38525a9a08
  1. 7
      src/core/ext/client_config/resolver_result.c
  2. 2
      src/core/ext/client_config/resolver_result.h
  3. 4
      src/core/ext/resolver/sockaddr/sockaddr_resolver.c

@ -47,6 +47,13 @@ grpc_addresses *grpc_addresses_create(size_t num_addresses) {
return addresses;
}
grpc_addresses *grpc_addresses_copy(grpc_addresses* addresses) {
grpc_addresses *new = grpc_addresses_create(addresses->num_addresses);
memcpy(new->addresses, addresses->addresses,
sizeof(grpc_address) * addresses->num_addresses);
return new;
}
void grpc_addresses_set_address(grpc_addresses *addresses, size_t index,
void *address, size_t address_len,
bool is_balancer) {

@ -54,6 +54,8 @@ typedef struct grpc_addresses {
\a num_addresses addresses. */
grpc_addresses *grpc_addresses_create(size_t num_addresses);
grpc_addresses *grpc_addresses_copy(grpc_addresses* addresses);
void grpc_addresses_set_address(grpc_addresses *addresses, size_t index,
void *address, size_t address_len,
bool is_balancer);

@ -120,8 +120,8 @@ static void sockaddr_maybe_finish_next_locked(grpc_exec_ctx *exec_ctx,
sockaddr_resolver *r) {
if (r->next_completion != NULL && !r->published) {
r->published = true;
*r->target_result =
grpc_resolver_result_create(r->addresses, r->lb_policy_name);
*r->target_result = grpc_resolver_result_create(
grpc_addresses_copy(r->addresses), r->lb_policy_name);
grpc_exec_ctx_sched(exec_ctx, r->next_completion, GRPC_ERROR_NONE, NULL);
r->next_completion = NULL;
}

Loading…
Cancel
Save