Use std::copy instead of OPENSSL_memcpy for the internal bssl::Array::CopyFrom This (internal) abstraction was originally made for trivial types, but if we ever got a complex type, we should use C++ copies, not C copies, to preserve all the rules of that type. A good STL will specialize std::copy to memmove/memcpy when possible, so this should not appreciably change the generated code. Change-Id: I76af334ef667e545dbbbe87315ce5b30a327358c Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66427 Commit-Queue: David Benjamin <davidben@google.com> Reviewed-by: Bob Beck <bbe@google.com>
diff --git a/ssl/internal.h b/ssl/internal.h index 1b30690..13b97da 100644 --- a/ssl/internal.h +++ b/ssl/internal.h
@@ -146,6 +146,7 @@ #include <stdlib.h> +#include <algorithm> #include <initializer_list> #include <limits> #include <new> @@ -317,7 +318,7 @@ if (!Init(in.size())) { return false; } - OPENSSL_memcpy(data_, in.data(), sizeof(T) * in.size()); + std::copy(in.begin(), in.end(), data_); return true; }