From: György Straub Date: Tue, 22 Dec 2020 13:50:36 +0000 (+0000) Subject: Fixed SVACE and related issues in dali-scene-loader. X-Git-Tag: dali_2.0.7~9 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=4b8ce75c615d3ebb84de69224a6210d3fd7cdea1;ds=sidebyside Fixed SVACE and related issues in dali-scene-loader. - sprintf() replaced with snprintf() in gltf2-loader; - ExceptionFlinger's destructor is marked as [[noreturn]]; other methods are marked noexcept(true); - fixed the assertion in MeshDefinition::Blob::ApplyMinMax(), where either min or max can be empty, or they have to be the same size; Change-Id: Ib05c2cde99fb3b3403c5993740fc2d72e2399f48 --- diff --git a/dali-scene-loader/public-api/gltf2-loader.cpp b/dali-scene-loader/public-api/gltf2-loader.cpp index ed08a41..451060b 100644 --- a/dali-scene-loader/public-api/gltf2-loader.cpp +++ b/dali-scene-loader/public-api/gltf2-loader.cpp @@ -903,13 +903,15 @@ float LoadBlendShapeKeyFrames(const std::string& path, const gt::Animation::Chan const float duration = LoadDataFromAccessors(path, input, output, inputDataBuffer, outputDataBuffer); char weightNameBuffer[32]; - char* const pWeightName = weightNameBuffer + sprintf(weightNameBuffer, "%s[", BLEND_SHAPE_WEIGHTS_UNIFORM.c_str()); + auto prefixSize = snprintf(weightNameBuffer, sizeof(weightNameBuffer), "%s[", BLEND_SHAPE_WEIGHTS_UNIFORM.c_str()); + char* const pWeightName = weightNameBuffer + prefixSize; + const auto remainingSize = sizeof(weightNameBuffer) - prefixSize; for (uint32_t weightIndex = 0u, endWeightIndex = channel.mSampler->mOutput->mCount / channel.mSampler->mInput->mCount; weightIndex < endWeightIndex; ++weightIndex) { AnimatedProperty& animatedProperty = properties[propertyIndex++]; animatedProperty.mNodeName = nodeName; - sprintf(pWeightName, "%d]", weightIndex); + snprintf(pWeightName, remainingSize, "%d]", weightIndex); animatedProperty.mPropertyName = std::string(weightNameBuffer); animatedProperty.mKeyFrames = KeyFrames::New(); diff --git a/dali-scene-loader/public-api/mesh-definition.cpp b/dali-scene-loader/public-api/mesh-definition.cpp index 19d4544..9823295 100644 --- a/dali-scene-loader/public-api/mesh-definition.cpp +++ b/dali-scene-loader/public-api/mesh-definition.cpp @@ -457,7 +457,7 @@ MeshDefinition::Accessor::Accessor(const MeshDefinition::Blob& blob, void MeshDefinition::Blob::ApplyMinMax(const std::vector& min, const std::vector& max, uint32_t count, float* values) { - DALI_ASSERT_DEBUG(max.empty() || max.size() == min.size()); + DALI_ASSERT_DEBUG(max.size() == min.size() || max.size() * min.size() == 0); const auto numComponents = std::max(min.size(), max.size()); using ClampFn = void(*)(const float*, const float*, uint32_t, float&); diff --git a/dali-scene-loader/public-api/utils.cpp b/dali-scene-loader/public-api/utils.cpp index 773bf17..382e118 100644 --- a/dali-scene-loader/public-api/utils.cpp +++ b/dali-scene-loader/public-api/utils.cpp @@ -35,7 +35,7 @@ namespace thread_local char sExceptionFlingerMessageBuffer[ExceptionFlinger::MESSAGE_BUFFER_SIZE]{}; } -char* ExceptionFlinger::GetMessageBuffer() +char* ExceptionFlinger::GetMessageBuffer() noexcept(true) { return sExceptionFlingerMessageBuffer; } diff --git a/dali-scene-loader/public-api/utils.h b/dali-scene-loader/public-api/utils.h index 09c30e1..3ab0c33 100644 --- a/dali-scene-loader/public-api/utils.h +++ b/dali-scene-loader/public-api/utils.h @@ -41,7 +41,7 @@ namespace SceneLoader class DALI_SCENE_LOADER_API StreamBuffer : public std::basic_streambuf { public: - StreamBuffer(char* buffer, size_t size) + StreamBuffer(char* buffer, size_t size) noexcept(true) { setp(buffer, buffer + size); } @@ -57,12 +57,13 @@ class DALI_SCENE_LOADER_API ExceptionFlinger public: enum { MESSAGE_BUFFER_SIZE = 512 }; - ExceptionFlinger(const char* location) + ExceptionFlinger(const char* location) noexcept(true) : mLocation(location), mStreamBuffer(GetMessageBuffer(), MESSAGE_BUFFER_SIZE - 1), mStream(&mStreamBuffer) {} + [[noreturn]] ~ExceptionFlinger() noexcept(false) { operator<<('\0'); @@ -70,14 +71,14 @@ public: } template - ExceptionFlinger& operator<<(const T& rhs) + ExceptionFlinger& operator<<(const T& rhs) noexcept(true) { mStream << rhs; return *this; } private: - static char* GetMessageBuffer(); + static char* GetMessageBuffer() noexcept(true); const char* mLocation; StreamBuffer mStreamBuffer;