Fix comparison to not crash

pull/1661/head
Craig Tiller 10 years ago
parent 3891bf11ff
commit c259988357
  1. 14
      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;

Loading…
Cancel
Save