From e4a1bc154266afe45e34df7c2d22cdc97639303d Mon Sep 17 00:00:00 2001 From: sin-ack Date: Sun, 12 Sep 2021 16:02:04 +0000 Subject: [PATCH] AK: Use __builtin_memmove for ByteBuffer and Span's overwrite __builtin_memcpy will fail when the target area and the source area overlap. Using __builtin_memmove will handle this case as well. --- AK/ByteBuffer.h | 2 +- AK/Span.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AK/ByteBuffer.h b/AK/ByteBuffer.h index c0cbe0b2ba..ce160e32a3 100644 --- a/AK/ByteBuffer.h +++ b/AK/ByteBuffer.h @@ -214,7 +214,7 @@ public: { // make sure we're not told to write past the end VERIFY(offset + data_size <= size()); - __builtin_memcpy(this->data() + offset, data, data_size); + __builtin_memmove(this->data() + offset, data, data_size); } void zero_fill() diff --git a/AK/Span.h b/AK/Span.h index 2de4af8da5..93e48bf911 100644 --- a/AK/Span.h +++ b/AK/Span.h @@ -144,7 +144,7 @@ public: { // make sure we're not told to write past the end VERIFY(offset + data_size <= size()); - __builtin_memcpy(this->data() + offset, data, data_size); + __builtin_memmove(this->data() + offset, data, data_size); } ALWAYS_INLINE constexpr size_t copy_to(Span> other) const