Add OPENSSL_zalloc OpenSSL added a similar helper function. It's very, very common for us to malloc something an then zero it. This saves some effort. Also replace some more malloc + memcpy pairs with memdup. Change-Id: I1e765c8774a0d15742827c39a1f16df9748ef247 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/63345 Reviewed-by: Bob Beck <bbe@google.com> Commit-Queue: David Benjamin <davidben@google.com> Auto-Submit: David Benjamin <davidben@google.com>
diff --git a/ssl/d1_both.cc b/ssl/d1_both.cc index 55c92fa..b910b96 100644 --- a/ssl/d1_both.cc +++ b/ssl/d1_both.cc
@@ -184,11 +184,10 @@ return nullptr; } size_t bitmask_len = (msg_hdr->msg_len + 7) / 8; - frag->reassembly = (uint8_t *)OPENSSL_malloc(bitmask_len); + frag->reassembly = (uint8_t *)OPENSSL_zalloc(bitmask_len); if (frag->reassembly == NULL) { return nullptr; } - OPENSSL_memset(frag->reassembly, 0, bitmask_len); } return frag;