From: Adeel Kazmi Date: Mon, 26 Mar 2018 16:59:40 +0000 (+0000) Subject: Merge "Fix Coverity issues" into devel/master X-Git-Tag: dali_1.3.18~2 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=83ac6481c584380eea8ebebadf337525e8a891d0;hp=c5e264bdf15b0a9fe1ef0c622b2f75dec6fd6168 Merge "Fix Coverity issues" into devel/master --- diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp index ebada51..af5f1a6 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-TextureManager.cpp @@ -66,7 +66,7 @@ int UtcTextureManagerRequestLoad(void) TextureManager::ReloadPolicy::CACHED, preMultiply); - const VisualUrl& url = textureManager.GetVisualUrl( textureId ); + VisualUrl url = textureManager.GetVisualUrl( textureId ); DALI_TEST_EQUALS( url.GetUrl().compare( filename ), 0, TEST_LOCATION ); diff --git a/dali-toolkit/internal/text/markup-processor.cpp b/dali-toolkit/internal/text/markup-processor.cpp index 5bbe5ad..25b4616 100755 --- a/dali-toolkit/internal/text/markup-processor.cpp +++ b/dali-toolkit/internal/text/markup-processor.cpp @@ -153,6 +153,11 @@ void Initialize( FontDescriptionRun& fontRun ) */ void ParseAttributes( Tag& tag ) { + if( tag.buffer == NULL ) + { + return; + } + tag.attributes.Resize( MAX_NUM_OF_ATTRIBUTES ); // Find first the tag name. diff --git a/dali-toolkit/internal/text/text-controller-impl.cpp b/dali-toolkit/internal/text/text-controller-impl.cpp index b40dba5..5f34488 100644 --- a/dali-toolkit/internal/text/text-controller-impl.cpp +++ b/dali-toolkit/internal/text/text-controller-impl.cpp @@ -106,6 +106,7 @@ EventData::EventData( DecoratorPtr decorator ) mAllTextSelected( false ), mUpdateInputStyle( false ), mPasswordInput( false ), + mCheckScrollAmount( false ), mIsPlaceholderPixelSize( false ), mIsPlaceholderElideEnabled( false ), mPlaceholderEllipsisFlag( false ), diff --git a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp index 13ce737..d216ff6 100755 --- a/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp +++ b/dali-toolkit/internal/visuals/animated-image/animated-image-visual.cpp @@ -332,7 +332,7 @@ void AnimatedImageVisual::DoSetProperty( Property::Index index, } case Toolkit::ImageVisual::Property::WRAP_MODE_U: { - int wrapMode; + int wrapMode = 0; if(Scripting::GetEnumerationProperty( value, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, wrapMode )) { mWrapModeU = Dali::WrapMode::Type(wrapMode); @@ -345,7 +345,7 @@ void AnimatedImageVisual::DoSetProperty( Property::Index index, } case Toolkit::ImageVisual::Property::WRAP_MODE_V: { - int wrapMode; + int wrapMode = 0; if(Scripting::GetEnumerationProperty( value, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, wrapMode )) { mWrapModeV = Dali::WrapMode::Type(wrapMode); diff --git a/dali-toolkit/internal/visuals/image/image-visual.cpp b/dali-toolkit/internal/visuals/image/image-visual.cpp index d475b39..6aaa271 100644 --- a/dali-toolkit/internal/visuals/image/image-visual.cpp +++ b/dali-toolkit/internal/visuals/image/image-visual.cpp @@ -410,7 +410,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v { case Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING: { - bool sync; + bool sync = false; if( value.Get( sync ) ) { if( sync ) @@ -431,7 +431,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::DESIRED_WIDTH: { - float desiredWidth; + float desiredWidth = 0.0f; if( value.Get( desiredWidth ) ) { mDesiredSize.SetWidth( desiredWidth ); @@ -445,7 +445,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::DESIRED_HEIGHT: { - float desiredHeight; + float desiredHeight = 0.0f; if( value.Get( desiredHeight ) ) { mDesiredSize.SetHeight( desiredHeight ); @@ -459,7 +459,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::FITTING_MODE: { - int fittingMode; + int fittingMode = 0; Scripting::GetEnumerationProperty( value, FITTING_MODE_TABLE, FITTING_MODE_TABLE_COUNT, fittingMode ); mFittingMode = Dali::FittingMode::Type( fittingMode ); break; @@ -467,7 +467,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::SAMPLING_MODE: { - int samplingMode; + int samplingMode = 0; Scripting::GetEnumerationProperty( value, SAMPLING_MODE_TABLE, SAMPLING_MODE_TABLE_COUNT, samplingMode ); mSamplingMode = Dali::SamplingMode::Type( samplingMode ); break; @@ -481,7 +481,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::WRAP_MODE_U: { - int wrapMode; + int wrapMode = 0; Scripting::GetEnumerationProperty( value, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, wrapMode ); mWrapModeU = Dali::WrapMode::Type( wrapMode ); break; @@ -489,7 +489,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::WRAP_MODE_V: { - int wrapMode; + int wrapMode = 0; Scripting::GetEnumerationProperty( value, WRAP_MODE_TABLE, WRAP_MODE_TABLE_COUNT, wrapMode ); mWrapModeV = Dali::WrapMode::Type( wrapMode ); break; @@ -503,7 +503,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::ALPHA_MASK_URL: { - std::string alphaUrl; + std::string alphaUrl = ""; if( value.Get( alphaUrl ) ) { AllocateMaskData(); @@ -517,7 +517,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::MASK_CONTENT_SCALE: { - float scale; + float scale = 1.0f; if( value.Get( scale ) ) { AllocateMaskData(); @@ -539,7 +539,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::RELEASE_POLICY: { - int releasePolicy; + int releasePolicy = 0; Scripting::GetEnumerationProperty( value, RELEASE_POLICY_TABLE, RELEASE_POLICY_TABLE_COUNT, releasePolicy ); mReleasePolicy = Toolkit::ImageVisual::ReleasePolicy::Type( releasePolicy ); break; @@ -547,7 +547,7 @@ void ImageVisual::DoSetProperty( Property::Index index, const Property::Value& v case Toolkit::ImageVisual::Property::LOAD_POLICY: { - int loadPolicy; + int loadPolicy = 0; Scripting::GetEnumerationProperty( value, LOAD_POLICY_TABLE, LOAD_POLICY_TABLE_COUNT, loadPolicy ); mLoadPolicy = Toolkit::ImageVisual::LoadPolicy::Type( loadPolicy ); break; diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.cpp b/dali-toolkit/internal/visuals/texture-manager-impl.cpp index 272ad4e..1ec606c 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.cpp +++ b/dali-toolkit/internal/visuals/texture-manager-impl.cpp @@ -474,13 +474,20 @@ void TextureManager::Remove( const TextureManager::TextureId textureId ) } } -const VisualUrl& TextureManager::GetVisualUrl( TextureId textureId ) +VisualUrl TextureManager::GetVisualUrl( TextureId textureId ) { + VisualUrl visualUrl(""); int cacheIndex = GetCacheIndexFromId( textureId ); - DALI_ASSERT_DEBUG( cacheIndex != INVALID_CACHE_INDEX && "TextureId out of range"); - TextureInfo& cachedTextureInfo( mTextureInfoContainer[ cacheIndex ] ); - return cachedTextureInfo.url; + if( cacheIndex != INVALID_CACHE_INDEX ) + { + DALI_LOG_INFO( gTextureManagerLogFilter, Debug::Concise, "TextureManager::GetVisualUrl. Using cached texture id=%d, textureId=%d\n", + cacheIndex, textureId ); + + TextureInfo& cachedTextureInfo( mTextureInfoContainer[ cacheIndex ] ); + visualUrl = cachedTextureInfo.url; + } + return visualUrl; } TextureManager::LoadState TextureManager::GetTextureState( TextureId textureId ) @@ -763,8 +770,11 @@ void TextureManager::ApplyMask( float contentScale, bool cropToMask ) { int maskCacheIndex = GetCacheIndexFromId( maskTextureId ); - Devel::PixelBuffer maskPixelBuffer = mTextureInfoContainer[maskCacheIndex].pixelBuffer; - pixelBuffer.ApplyMask( maskPixelBuffer, contentScale, cropToMask ); + if( maskCacheIndex != INVALID_CACHE_INDEX ) + { + Devel::PixelBuffer maskPixelBuffer = mTextureInfoContainer[maskCacheIndex].pixelBuffer; + pixelBuffer.ApplyMask( maskPixelBuffer, contentScale, cropToMask ); + } } diff --git a/dali-toolkit/internal/visuals/texture-manager-impl.h b/dali-toolkit/internal/visuals/texture-manager-impl.h index 8685ec6..b8c6ab8 100644 --- a/dali-toolkit/internal/visuals/texture-manager-impl.h +++ b/dali-toolkit/internal/visuals/texture-manager-impl.h @@ -307,9 +307,11 @@ public: void Remove( const TextureManager::TextureId textureId ); /** - * Get the visualUrl associated with the texture id + * @brief Get the visualUrl associated with the texture id. + * @param[in] textureId The texture Id to get + * @return The visual Url associated with the texture id. */ - const VisualUrl& GetVisualUrl( TextureId textureId ); + VisualUrl GetVisualUrl( TextureId textureId ); /** * @brief Get the current state of a texture diff --git a/dali-toolkit/third-party/nanosvg/nanosvg.cc b/dali-toolkit/third-party/nanosvg/nanosvg.cc index 1022a98..603f977 100644 --- a/dali-toolkit/third-party/nanosvg/nanosvg.cc +++ b/dali-toolkit/third-party/nanosvg/nanosvg.cc @@ -2753,14 +2753,21 @@ NSVGimage* nsvgParse(char* input, const char* units, float dpi) NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi) { FILE* fp = NULL; - size_t size; + size_t size = 0; + long value = 0; char* data = NULL; NSVGimage* image = NULL; fp = fopen(filename, "rb"); if (!fp) goto error; fseek(fp, 0, SEEK_END); - size = ftell(fp); + value = ftell(fp); + /** + * In the original file, unsigned long type 'size' gets a return value. But, the return value of 'ftell()' is + * signed long type. To prevent interpreting an unexpected large value, we put the comparitive condition here. + */ + if( value < 0 ) goto error; + size = value; fseek(fp, 0, SEEK_SET); data = (char*)malloc(size+1); if (data == NULL) goto error;