From a5db742d3c3056ad1b01685cc694d707437e1f39 Mon Sep 17 00:00:00 2001 From: Bram Oosterhuis Date: Mon, 29 Jan 2024 12:26:21 +0100 Subject: [PATCH] CompositorBuffer: do not initialize members after mmap --- .../compositorbuffer/CompositorBufferType.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Source/compositorbuffer/include/compositorbuffer/CompositorBufferType.h b/Source/compositorbuffer/include/compositorbuffer/CompositorBufferType.h index 7d5603c..f0fd2fb 100644 --- a/Source/compositorbuffer/include/compositorbuffer/CompositorBufferType.h +++ b/Source/compositorbuffer/include/compositorbuffer/CompositorBufferType.h @@ -67,16 +67,12 @@ namespace Compositor { SharedStorage(const SharedStorage&) = delete; SharedStorage& operator=(const SharedStorage&) = delete; - SharedStorage() - : _width(0) - , _height(0) - , _format(0) - , _modifier(0) - , _type(Exchange::ICompositionBuffer::TYPE_INVALID) - , _dirty() - , _copyOfDirty(false) - { - } + // FIXME: + // Do not initialize members for now, this constructor is called after a mmap in the + // placement new operator above. Initializing them now will reset the original values + // of the buffer metadata. + SharedStorage(){}; + SharedStorage(const uint32_t width, const uint32_t height, const uint32_t format, const uint64_t modifier, const Exchange::ICompositionBuffer::DataType type) : _width(width) , _height(height) @@ -325,7 +321,7 @@ namespace Compositor { ASSERT(_virtualFd != -1); - _storage = new (_virtualFd) SharedStorage(); + _storage = new (_virtualFd) SharedStorage; if (_storage == nullptr) { ::close(_virtualFd); } else {