From 1feef2e276cefaab9dfbf83b19b01a54afea1709 Mon Sep 17 00:00:00 2001 From: "Evgeniy A. Dushistov" Date: Mon, 12 Oct 2026 17:07:23 +0300 Subject: [PATCH] fix: writing outside of sharedBuffer if size small enough valgrind catch in rather old couchbase-lite-core write of 8 bytes to place, for each was allocated only 4. So that's why this fix. Plus I suppose it is C++ standard violation to allocate less them sizeof(type): ``` The lifetime of an object of type T begins when: (2.1) storage with the proper alignment and size for type T is obtained ``` --- Fleece/API_Impl/FLSlice.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Fleece/API_Impl/FLSlice.cc b/Fleece/API_Impl/FLSlice.cc index 6b45b8b3..766d26cb 100644 --- a/Fleece/API_Impl/FLSlice.cc +++ b/Fleece/API_Impl/FLSlice.cc @@ -117,7 +117,7 @@ namespace fleece { uint8_t _buf[4]; static inline void* operator new(size_t basicSize, size_t bufferSize) noexcept { - return malloc(basicSize - sizeof(sharedBuffer::_buf) + bufferSize); + return malloc(basicSize - sizeof(sharedBuffer::_buf) + std::max(bufferSize, sizeof(sharedBuffer::_buf))); } static inline void operator delete(void *self) {