diff options
author | Craig Tiller <ctiller@google.com> | 2015-05-19 15:47:19 -0700 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-05-19 15:47:19 -0700 |
commit | c259988357f3722b9d0ee7b55bcb818425d15ece (patch) | |
tree | a6faea702480f0548873ac39c7667ced3388d05e /test/core | |
parent | 3891bf11ff94f0f8afb05ebd49f1ccca2e3803e3 (diff) |
Fix comparison to not crash
Diffstat (limited to 'test/core')
-rw-r--r-- | test/core/end2end/cq_verifier.c | 14 |
1 files 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; |