/*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Hash hash = hashedName;
std::string_view match = name;
+ int arrayIndex = 0;
+
if(!name.empty() && name.back() == ']')
{
- hash = hashedNameNoArray;
auto pos = name.rfind("[");
- match = name.substr(0, pos - 1); // Remove subscript
+ if(pos != std::string::npos)
+ {
+ hash = hashedNameNoArray;
+ match = name.substr(0, pos); // Remove subscript
+ arrayIndex = atoi(&name[pos + 1]);
+ }
}
for(const ReflectionUniformInfo& item : mReflection)
if(!item.hasCollision || item.uniformInfo.name == match)
{
out = item.uniformInfo;
+
+ // Array out of bounds
+ if(item.uniformInfo.elementCount > 0 && arrayIndex >= int(item.uniformInfo.elementCount))
+ {
+ DALI_LOG_ERROR("Uniform %s, array index out of bound [%d >= %d]!\n",
+ item.uniformInfo.name.c_str(),
+ int(arrayIndex),
+ int(item.uniformInfo.elementCount));
+ return false;
+ }
return true;
}
else