From: György Straub Date: Wed, 23 Dec 2020 11:29:58 +0000 (+0000) Subject: Fixed the SVACE issue in ExceptionFlinger. X-Git-Tag: dali_2.0.7~6 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=15fd5e6e5255907196593306e19a7f5adcf421c2;ds=sidebyside Fixed the SVACE issue in ExceptionFlinger. 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 --- 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; };