From c259988357f3722b9d0ee7b55bcb818425d15ece Mon Sep 17 00:00:00 2001
From: Craig Tiller <ctiller@google.com>
Date: Tue, 19 May 2015 15:47:19 -0700
Subject: [PATCH] Fix comparison to not crash

---
 test/core/end2end/cq_verifier.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c
index 66480254d2..7822d001d1 100644
--- a/test/core/end2end/cq_verifier.c
+++ b/test/core/end2end/cq_verifier.c
@@ -127,11 +127,15 @@ static gpr_slice merge_slices(gpr_slice *slices, size_t nslices) {
 }
 
 static int byte_buffer_eq_slice(grpc_byte_buffer *bb, gpr_slice b) {
-  gpr_slice a =
-      merge_slices(bb->data.slice_buffer.slices, bb->data.slice_buffer.count);
-  int ok = GPR_SLICE_LENGTH(a) == GPR_SLICE_LENGTH(b) &&
-           0 == memcmp(GPR_SLICE_START_PTR(a), GPR_SLICE_START_PTR(b),
-                       GPR_SLICE_LENGTH(a));
+  gpr_slice a;
+  int ok;
+
+  if (!bb) return 0;
+
+  a = merge_slices(bb->data.slice_buffer.slices, bb->data.slice_buffer.count);
+  ok = GPR_SLICE_LENGTH(a) == GPR_SLICE_LENGTH(b) &&
+       0 == memcmp(GPR_SLICE_START_PTR(a), GPR_SLICE_START_PTR(b),
+                   GPR_SLICE_LENGTH(a));
   gpr_slice_unref(a);
   gpr_slice_unref(b);
   return ok;
-- 
GitLab