From 0c0e36e37f22d0d2f555e89441448f1e4bc24d59 Mon Sep 17 00:00:00 2001 From: Kevin Lubick Date: Wed, 18 Jan 2023 12:58:59 -0500 Subject: [PATCH] Remove use of SkTAddOffset and sk_careful_memcpy (flutter/engine#38977) --- .../src/flutter/display_list/display_list_builder.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engine/src/flutter/display_list/display_list_builder.cc b/engine/src/flutter/display_list/display_list_builder.cc index cdc400b192..970601b53c 100644 --- a/engine/src/flutter/display_list/display_list_builder.cc +++ b/engine/src/flutter/display_list/display_list_builder.cc @@ -23,8 +23,14 @@ static void CopyV(void* dst, const S* src, int n, Rest&&... rest) { FML_DCHECK(((uintptr_t)dst & (alignof(S) - 1)) == 0) << "Expected " << dst << " to be aligned for at least " << alignof(S) << " bytes."; - sk_careful_memcpy(dst, src, n * sizeof(S)); - CopyV(SkTAddOffset(dst, n * sizeof(S)), std::forward(rest)...); + // If n is 0, there is nothing to copy into dst from src. + if (n > 0) { + memcpy(dst, src, n * sizeof(S)); + dst = reinterpret_cast(reinterpret_cast(dst) + + n * sizeof(S)); + } + // Repeat for the next items, if any + CopyV(dst, std::forward(rest)...); } static constexpr inline bool is_power_of_two(int value) {