|  | @@ -69,6 +69,10 @@ PHP_GRPC_FREE_WRAPPED_FUNC_START(wrapped_grpc_channel)
 | 
	
		
			
				|  |  |          grpc_channel_destroy(p->wrapper->wrapped);
 | 
	
		
			
				|  |  |          free(p->wrapper->target);
 | 
	
		
			
				|  |  |          free(p->wrapper->args_hashstr);
 | 
	
		
			
				|  |  | +        if (p->wrapper->creds_hashstr != NULL) {
 | 
	
		
			
				|  |  | +          free(p->wrapper->creds_hashstr);
 | 
	
		
			
				|  |  | +          p->wrapper->creds_hashstr = NULL;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        gpr_mu_unlock(&global_persistent_list_mu);
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -277,9 +281,14 @@ PHP_METHOD(Channel, __construct) {
 | 
	
		
			
				|  |  |    channel->wrapper->key = key;
 | 
	
		
			
				|  |  |    channel->wrapper->target = strdup(target);
 | 
	
		
			
				|  |  |    channel->wrapper->args_hashstr = strdup(sha1str);
 | 
	
		
			
				|  |  | +  channel->wrapper->creds_hashstr = NULL;
 | 
	
		
			
				|  |  |    if (creds != NULL && creds->hashstr != NULL) {
 | 
	
		
			
				|  |  | -    channel->wrapper->creds_hashstr = creds->hashstr;
 | 
	
		
			
				|  |  | +    php_grpc_int creds_hashstr_len = strlen(creds->hashstr);
 | 
	
		
			
				|  |  | +    char *channel_creds_hashstr = malloc(creds_hashstr_len + 1);
 | 
	
		
			
				|  |  | +    strcpy(channel_creds_hashstr, creds->hashstr);
 | 
	
		
			
				|  |  | +    channel->wrapper->creds_hashstr = channel_creds_hashstr;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    gpr_mu_init(&channel->wrapper->mu);
 | 
	
		
			
				|  |  |    smart_str_free(&buf);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -304,6 +313,11 @@ PHP_METHOD(Channel, __construct) {
 | 
	
		
			
				|  |  |            channel, target, args, creds, key, key_len TSRMLS_CC);
 | 
	
		
			
				|  |  |      } else {
 | 
	
		
			
				|  |  |        efree(args.args);
 | 
	
		
			
				|  |  | +      if (channel->wrapper->creds_hashstr != NULL){
 | 
	
		
			
				|  |  | +        free(channel->wrapper->creds_hashstr);
 | 
	
		
			
				|  |  | +        channel->wrapper->creds_hashstr = NULL;
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      free(channel->wrapper->creds_hashstr);
 | 
	
		
			
				|  |  |        channel->wrapper = le->channel;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -418,6 +432,10 @@ PHP_METHOD(Channel, close) {
 | 
	
		
			
				|  |  |      grpc_channel_destroy(channel->wrapper->wrapped);
 | 
	
		
			
				|  |  |      free(channel->wrapper->target);
 | 
	
		
			
				|  |  |      free(channel->wrapper->args_hashstr);
 | 
	
		
			
				|  |  | +    if (channel->wrapper->creds_hashstr != NULL) {
 | 
	
		
			
				|  |  | +      free(channel->wrapper->creds_hashstr);
 | 
	
		
			
				|  |  | +      channel->wrapper->creds_hashstr = NULL;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      channel->wrapper->wrapped = NULL;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      php_grpc_delete_persistent_list_entry(channel->wrapper->key,
 |