diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c index 47483812b25..e9b6d67f817 100644 --- a/src/php/ext/grpc/channel.c +++ b/src/php/ext/grpc/channel.c @@ -50,7 +50,7 @@ extern HashTable grpc_persistent_list; extern HashTable grpc_target_upper_bound_map; void free_grpc_channel_wrapper(grpc_channel_wrapper* channel, bool free_channel) { - if (free_channel) { + if (free_channel && channel->wrapped) { grpc_channel_destroy(channel->wrapped); channel->wrapped = NULL; } diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index f567d8c59c3..01764a71202 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -159,6 +159,7 @@ void destroy_grpc_channels() { wrapped_channel.wrapper = le->channel; grpc_channel_wrapper *channel = wrapped_channel.wrapper; grpc_channel_destroy(channel->wrapped); + channel->wrapped = NULL; PHP_GRPC_HASH_FOREACH_END() }