[Tizen] Prevent invalid access to array 42/267642/1 accepted/tizen/6.5/unified/20211212.212850 submit/tizen_6.5/20211209.112504
authorHeeyong Song <heeyong.song@samsung.com>
Wed, 8 Dec 2021 06:20:37 +0000 (15:20 +0900)
committerHeeyong Song <heeyong.song@samsung.com>
Wed, 8 Dec 2021 06:21:14 +0000 (15:21 +0900)
Change-Id: I75b61a9dd9bfa3c69b6fbe8f8dbd947b3c031d89

dali/internal/graphics/gles-impl/gles-context-state-cache.h
dali/internal/graphics/gles-impl/gles-context.cpp

index 07f1512..808c90e 100644 (file)
@@ -101,7 +101,7 @@ struct GLStateCache
   GLuint mBoundElementArrayBufferId{0}; ///< The ID passed to glBindBuffer(GL_ELEMENT_ARRAY_BUFFER)
 
   // glBindTexture() state
-  GLenum mActiveTextureUnit{MAX_TEXTURE_UNITS};
+  GLenum mActiveTextureUnit{0};
   GLuint mBoundTextureId[MAX_TEXTURE_UNITS][MAX_TEXTURE_TARGET]; ///< The ID passed to glBindTexture()
 
   // glBlendFuncSeparate() state
index 9c21096..ff60310 100644 (file)
@@ -852,7 +852,7 @@ void Context::SetDepthWriteEnable(bool depthWriteEnable)
 
 void Context::ActiveTexture(uint32_t textureBindingIndex)
 {
-  if(mImpl->mGlStateCache.mActiveTextureUnit != textureBindingIndex)
+  if(mImpl->mGlStateCache.mActiveTextureUnit != textureBindingIndex && textureBindingIndex < MAX_TEXTURE_UNITS)
   {
     mImpl->mGlStateCache.mActiveTextureUnit = textureBindingIndex;
 
@@ -867,7 +867,7 @@ void Context::BindTexture(GLenum target, BoundTextureType textureTypeId, uint32_
   if(mImpl->mGlStateCache.mActiveTextureUnit >= MAX_TEXTURE_UNITS || typeId >= MAX_TEXTURE_TARGET)
   {
     DALI_LOG_ERROR("Invalid index (%d, %d)\n", mImpl->mGlStateCache.mActiveTextureUnit, typeId);
-    std::abort();
+    return;
   }
 
   if(mImpl->mGlStateCache.mBoundTextureId[mImpl->mGlStateCache.mActiveTextureUnit][typeId] != textureId)