[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 <andrew.cox@partner.samsung.com>
// INTERNAL INCLUDES
#include <dali/public-api/common/constants.h> // for Color::BLACK
#include <dali/internal/render/common/render-tracker.h>
+#include <dali/integration-api/debug.h>
namespace Dali
{
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 ];
}
* 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;