Fix ReuseRenderer issue when renderer is nullptr 18/267418/3
authorEunki, Hong <eunkiki.hong@samsung.com>
Fri, 3 Dec 2021 04:21:51 +0000 (13:21 +0900)
committerEunki, Hong <eunkiki.hong@samsung.com>
Fri, 3 Dec 2021 07:23:39 +0000 (16:23 +0900)
When ClippingMode is CLIP_TO_BOUNDING_BOX and it have no children,
we add nullptr SceneGraph::Renderer into renderables.

Previous codes are assume that that renderers are not nullptr
so they just use many of memberfunctions.

This patch fix the dangerous nullptr access.

TODO : need to make UTC

Change-Id: If04ff5a68ef95c27fbe43166eb64734d681bcdaa
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
dali/internal/update/manager/render-instruction-processor.cpp

index 15a58e8..ce5d270 100644 (file)
@@ -242,7 +242,7 @@ inline void AddRendererToRenderList(BufferIndex         updateBufferIndex,
       partialRenderingCacheInfo.color      = node->GetColor(updateBufferIndex);
       partialRenderingCacheInfo.depthIndex = node->GetDepthIndex();
 
-      if(renderable.mRenderer)
+      if(DALI_LIKELY(renderable.mRenderer))
       {
         partialRenderingCacheInfo.textureSet = renderable.mRenderer->GetTextureSet();
       }
@@ -362,9 +362,15 @@ inline bool TryReuseCachedRenderers(Layer&               layer,
     size_t checkSumOld = 0;
     for(uint32_t index = 0; index < renderableCount; ++index)
     {
-      const Render::Renderer& renderer = renderables[index].mRenderer->GetRenderer();
-      checkSumNew += reinterpret_cast<std::size_t>(&renderer);
-      checkSumOld += reinterpret_cast<std::size_t>(&renderList.GetRenderer(index));
+      if(DALI_LIKELY(renderables[index].mRenderer))
+      {
+        const Render::Renderer& renderer = renderables[index].mRenderer->GetRenderer();
+        checkSumNew += reinterpret_cast<std::size_t>(&renderer);
+      }
+      if(DALI_LIKELY(renderList.GetItem(index).mRenderer))
+      {
+        checkSumOld += reinterpret_cast<std::size_t>(&renderList.GetRenderer(index));
+      }
     }
     if(checkSumNew == checkSumOld)
     {
@@ -433,7 +439,7 @@ inline void RenderInstructionProcessor::SortRenderItems(BufferIndex bufferIndex,
     {
       RenderItem& item = renderList.GetItem(index);
 
-      if(item.mRenderer)
+      if(DALI_LIKELY(item.mRenderer))
       {
         item.mRenderer->SetSortAttributes(mSortingHelper[index]);
       }
@@ -455,7 +461,10 @@ inline void RenderInstructionProcessor::SortRenderItems(BufferIndex bufferIndex,
     {
       RenderItem& item = renderList.GetItem(index);
 
-      item.mRenderer->SetSortAttributes(mSortingHelper[index]);
+      if(DALI_LIKELY(item.mRenderer))
+      {
+        item.mRenderer->SetSortAttributes(mSortingHelper[index]);
+      }
 
       // texture set
       mSortingHelper[index].textureSet = item.mTextureSet;