[Tizen] Add log to prevent invalid access to array 08/265808/1
authorHeeyong Song <heeyong.song@samsung.com>
Fri, 29 Oct 2021 05:30:22 +0000 (14:30 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Fri, 29 Oct 2021 05:30:22 +0000 (14:30 +0900)
Change-Id: I6b9d3b3b45a74d78865ae0842a4a6f8b59839930

dali/internal/graphics/gles-impl/gles-context.cpp

index 13c1bad..1d19149 100644 (file)
@@ -29,6 +29,7 @@
 #include "gles-graphics-render-target.h"
 
 #include <map>
+#include <assert.h>
 
 namespace Dali::Graphics::GLES
 {
@@ -860,6 +861,12 @@ void Context::ActiveTexture(uint32_t textureBindingIndex)
 void Context::BindTexture(GLenum target, BoundTextureType textureTypeId, uint32_t textureId)
 {
   uint32_t typeId = static_cast<uint32_t>(textureTypeId);
+  if(mImpl->mGlStateCache.mActiveTextureUnit >= MAX_TEXTURE_UNITS || typeId >= MAX_TEXTURE_TARGET)
+  {
+    DALI_LOG_ERROR("Invalid index (%d, %d)\n", mImpl->mGlStateCache.mActiveTextureUnit, typeId);
+    assert(0);
+  }
+
   if(mImpl->mGlStateCache.mBoundTextureId[mImpl->mGlStateCache.mActiveTextureUnit][typeId] != textureId)
   {
     mImpl->mGlStateCache.mBoundTextureId[mImpl->mGlStateCache.mActiveTextureUnit][typeId] = textureId;