Removed AssertAlways and added error logging in RenderInstruction::GetRenderList(). 64/34264/2
authorAndrew Cox <andrew.cox@partner.samsung.com>
Thu, 22 Jan 2015 10:46:52 +0000 (10:46 +0000)
committerAndrew Cox <andrew.cox@partner.samsung.com>
Thu, 22 Jan 2015 14:34:04 +0000 (14:34 +0000)
[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>
dali/internal/render/common/render-instruction.cpp
dali/internal/render/common/render-instruction.h

index 5e38169..74f641b 100644 (file)
@@ -21,6 +21,7 @@
 // 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
 {
@@ -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 ];
 }
 
index e0c2c12..3713f99 100644 (file)
@@ -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;