UI: IocContainer: Check array index.

This commit is contained in:
Nodir Temirkhodjaev 2021-06-07 13:34:29 +03:00
parent e15cb97f0f
commit 3cd7bb7db0
2 changed files with 2 additions and 1 deletions

View File

@ -17,7 +17,7 @@ void IocContainer::setObject(int typeId, IocObject *obj, quint8 flags)
{
const int newSize = typeId + 1;
if (newSize > m_size) {
if (Q_UNLIKELY(newSize > IOC_MAX_SIZE)) {
if (Q_UNLIKELY(newSize >= IOC_MAX_SIZE)) {
qCritical() << "IoC Container size error";
Q_UNREACHABLE();
abort();

View File

@ -88,6 +88,7 @@ public:
static int getTypeId()
{
static const int typeId = getNextTypeId();
Q_ASSERT(typeId < IOC_MAX_SIZE);
return typeId;
}