From effbeb5bdbe3709459e22438681726ccef182c9b Mon Sep 17 00:00:00 2001 From: Agnelo Vaz Date: Fri, 3 Jan 2020 11:47:05 +0000 Subject: [PATCH] Fixing 4 SVACE errors Dereference of null pointer Asserts if unsigned ints not greater or equal to zero Change-Id: Ief535cdd8fe70e2e0deed3f721e612bb2a7facb0 --- dali-toolkit/internal/text/layouts/layout-engine.cpp | 4 ++-- .../animated-vector-image/vector-animation-task.cpp | 4 ++-- dali-toolkit/internal/visuals/visual-factory-impl.cpp | 16 ++++++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/dali-toolkit/internal/text/layouts/layout-engine.cpp b/dali-toolkit/internal/text/layouts/layout-engine.cpp index d73ee6a..525e031 100755 --- a/dali-toolkit/internal/text/layouts/layout-engine.cpp +++ b/dali-toolkit/internal/text/layouts/layout-engine.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -721,7 +721,7 @@ struct Engine::Impl // Convert the character in the visual order into the glyph in the visual order. const GlyphIndex glyphIndex = *( charactersToGlyphsBuffer + characterVisualIndex ) + index; - DALI_ASSERT_DEBUG( 0u <= glyphIndex && glyphIndex < layoutParameters.textModel->mVisualModel->mGlyphs.Count() ); + DALI_ASSERT_DEBUG( glyphIndex < layoutParameters.textModel->mVisualModel->mGlyphs.Count() ); const GlyphInfo& glyph = *( glyphsBuffer + glyphIndex ); Vector2& position = *( glyphPositionsBuffer + glyphIndex - layoutParameters.startGlyphIndex ); diff --git a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp index f8598ab..ae66146 100644 --- a/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp +++ b/dali-toolkit/internal/visuals/animated-vector-image/vector-animation-task.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -256,7 +256,7 @@ void VectorAnimationTask::SetPlayRange( Property::Array& playRange ) } // Make sure the range specified is between 0 and the total frame number - if( startFrame >= 0 && startFrame < mTotalFrame && endFrame >= 0 && endFrame < mTotalFrame ) + if( startFrame < mTotalFrame && endFrame < mTotalFrame ) { // If the range is not in order swap values if( startFrame > endFrame ) diff --git a/dali-toolkit/internal/visuals/visual-factory-impl.cpp b/dali-toolkit/internal/visuals/visual-factory-impl.cpp index 2c8183c..dcc997b 100644 --- a/dali-toolkit/internal/visuals/visual-factory-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-factory-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -281,11 +281,15 @@ Toolkit::Visual::Base VisualFactory::CreateVisual( const Property::Map& property Scripting::GetEnumerationName( visualType, VISUAL_TYPE_TABLE, VISUAL_TYPE_TABLE_COUNT ), - visualType==Toolkit::DevelVisual::IMAGE?"url:":"", - visualType==Toolkit::DevelVisual::IMAGE ? - propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME)->Get().c_str() - :"" ); - + ( visualType == Toolkit::DevelVisual::IMAGE ) ? "url:" : "", + ( visualType == Toolkit::DevelVisual::IMAGE ) ? + ( ([&] (){ + // Return URL if present in PropertyMap else return "not found message" + Property::Value* imageURLValue = propertyMap.Find( Toolkit::ImageVisual::Property::URL, IMAGE_URL_NAME ); + return ( imageURLValue ) ? imageURLValue->Get().c_str() : "url not found in PropertyMap"; + })() + ) + : "" ); if( !visualPtr ) { -- 2.7.4