From 2f04c6e25849cc29e3427b37a2e3395c5d1f1a08 Mon Sep 17 00:00:00 2001
From: yang-g <yangg@google.com>
Date: Fri, 31 Jul 2015 22:02:22 -0700
Subject: [PATCH] check before unref, this will fail in BadCreds test

---
 src/core/surface/channel.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c
index 81f673f856..688a586e18 100644
--- a/src/core/surface/channel.c
+++ b/src/core/surface/channel.c
@@ -229,7 +229,9 @@ static void destroy_channel(void *p, int ok) {
     registered_call *rc = channel->registered_calls;
     channel->registered_calls = rc->next;
     GRPC_MDELEM_UNREF(rc->path);
-    GRPC_MDELEM_UNREF(rc->authority);
+    if (rc->authority) {
+      GRPC_MDELEM_UNREF(rc->authority);
+    }
     gpr_free(rc);
   }
   grpc_mdctx_unref(channel->metadata_context);
-- 
GitLab