From 837cbee3153526ba1be7d17ef69b28360feca76a Mon Sep 17 00:00:00 2001 From: Andrew Cox Date: Thu, 22 Jan 2015 10:46:52 +0000 Subject: [PATCH] Removed AssertAlways and added error logging in RenderInstruction::GetRenderList(). [problem] Deep internal member function arbitrarily ending process if array index is out of bounds. [cause] Use of AssertAlways macro to check argument. [solution] Debug assertion and defensive code for release builds. Change-Id: I5e235869cb63484c74365d9d97b4c2772d65dcea Signed-off-by: Andrew Cox --- dali/internal/render/common/render-instruction.cpp | 10 +++++++++- dali/internal/render/common/render-instruction.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dali/internal/render/common/render-instruction.cpp b/dali/internal/render/common/render-instruction.cpp index 5e38169..74f641b 100644 --- a/dali/internal/render/common/render-instruction.cpp +++ b/dali/internal/render/common/render-instruction.cpp @@ -21,6 +21,7 @@ // INTERNAL INCLUDES #include // for Color::BLACK #include +#include namespace Dali { @@ -93,7 +94,14 @@ RenderListContainer::SizeType RenderInstruction::RenderListCount() const const RenderList* RenderInstruction::GetRenderList( RenderListContainer::SizeType index ) const { - DALI_ASSERT_ALWAYS( (index < mNextFreeRenderList ) && "Renderlist index out of scope" ); + DALI_ASSERT_DEBUG( (index < mNextFreeRenderList ) && (index < mRenderLists.Size()) && "Renderlist index out of container bounds" ); + + // Return null if the caller has passed an invalid index: + if( index >= std::min( mNextFreeRenderList, mRenderLists.Size() ) ) + { + return 0; + } + return mRenderLists[ index ]; } diff --git a/dali/internal/render/common/render-instruction.h b/dali/internal/render/common/render-instruction.h index e0c2c12..3713f99 100644 --- a/dali/internal/render/common/render-instruction.h +++ b/dali/internal/render/common/render-instruction.h @@ -79,7 +79,7 @@ public: * Return the renderlist at given index * @pre index is inside the valid range of initialized lists * @param index of list to return - * @return pointer to the renderlist + * @return pointer to the renderlist, or null if the index is out of bounds. */ const RenderList* GetRenderList( RenderListContainer::SizeType index ) const; -- 2.7.4