From 15fd5e6e5255907196593306e19a7f5adcf421c2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gy=C3=B6rgy=20Straub?= Date: Wed, 23 Dec 2020 11:29:58 +0000 Subject: [PATCH] Fixed the SVACE issue in ExceptionFlinger. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This ensures that the exception is only thrown following the destruction of all other data members. Change-Id: Ice35cc81130a056c168e7124b0277ec32a9526ce Signed-off-by: György Straub --- dali-scene-loader/public-api/utils.cpp | 8 ++++++-- dali-scene-loader/public-api/utils.h | 10 +++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/dali-scene-loader/public-api/utils.cpp b/dali-scene-loader/public-api/utils.cpp index dbfb8e8..8b8132e 100644 --- a/dali-scene-loader/public-api/utils.cpp +++ b/dali-scene-loader/public-api/utils.cpp @@ -40,8 +40,13 @@ StreamBuffer::StreamBuffer(char* buffer, size_t size) noexcept(true) setp(buffer, buffer + size); } +ExceptionFlinger::Impl::~Impl() noexcept(false) +{ + throw DaliException(mLocation, GetMessageBuffer()); +} + ExceptionFlinger::ExceptionFlinger(const char* location) noexcept(true) -: mLocation(location), +: mImpl{ location }, mStreamBuffer(GetMessageBuffer(), MESSAGE_BUFFER_SIZE - 1), mStream(&mStreamBuffer) {} @@ -49,7 +54,6 @@ ExceptionFlinger::ExceptionFlinger(const char* location) noexcept(true) ExceptionFlinger::~ExceptionFlinger() noexcept(false) { operator<<('\0'); - throw DaliException(mLocation, GetMessageBuffer()); } char* ExceptionFlinger::GetMessageBuffer() noexcept(true) diff --git a/dali-scene-loader/public-api/utils.h b/dali-scene-loader/public-api/utils.h index 70009a2..1aace35 100644 --- a/dali-scene-loader/public-api/utils.h +++ b/dali-scene-loader/public-api/utils.h @@ -67,9 +67,17 @@ public: } private: + struct Impl + { + const char* mLocation; + + [[noreturn]] + ~Impl() noexcept(false); + }; + static char* GetMessageBuffer() noexcept(true); - const char* mLocation; + Impl mImpl; StreamBuffer mStreamBuffer; std::ostream mStream; }; -- 2.7.4