From c619c49fab00c3348ee50da46f4a11d91ecee038 Mon Sep 17 00:00:00 2001 From: Jerry Date: Thu, 7 Mar 2019 17:31:34 -0800 Subject: [PATCH 1/2] fixed seg fault caused by access client after it is closed --- src/php/ext/grpc/call.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c index a7942262987..668095cfbd2 100644 --- a/src/php/ext/grpc/call.c +++ b/src/php/ext/grpc/call.c @@ -217,6 +217,12 @@ PHP_METHOD(Call, __construct) { } wrapped_grpc_channel *channel = PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_channel, channel_obj); + if (channel->wrapper == NULL || channel->wrapper->wrapped == NULL) { + zend_throw_exception(spl_ce_InvalidArgumentException, + "Call cannot be constructed from a closed Channel", + 1 TSRMLS_CC); + return; + } gpr_mu_lock(&channel->wrapper->mu); if (channel->wrapper == NULL || channel->wrapper->wrapped == NULL) { zend_throw_exception(spl_ce_InvalidArgumentException, From e2aef4d373089d0068666cc87502c18449358831 Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 8 Mar 2019 10:48:56 -0800 Subject: [PATCH 2/2] fixed seg fault --- src/php/ext/grpc/call.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c index 668095cfbd2..46d1e22f1f8 100644 --- a/src/php/ext/grpc/call.c +++ b/src/php/ext/grpc/call.c @@ -217,7 +217,7 @@ PHP_METHOD(Call, __construct) { } wrapped_grpc_channel *channel = PHP_GRPC_GET_WRAPPED_OBJECT(wrapped_grpc_channel, channel_obj); - if (channel->wrapper == NULL || channel->wrapper->wrapped == NULL) { + if (channel->wrapper == NULL) { zend_throw_exception(spl_ce_InvalidArgumentException, "Call cannot be constructed from a closed Channel", 1 TSRMLS_CC);