Added additional checks for SetProperty() of Material and MaterialInstance
This commit is contained in:
parent
8869b42db2
commit
19bc90845f
|
@ -84,6 +84,11 @@ namespace SHADE
|
|||
template<typename T>
|
||||
void SHMaterial::setPropertyUnsafe(uint32_t memOffset, const T& value)
|
||||
{
|
||||
// Size check
|
||||
if (memOffset + sizeof(T) > propMemorySize)
|
||||
{
|
||||
throw std::runtime_error("Attempted to write to out of bounds MaterialInstance properties memory");
|
||||
}
|
||||
(*reinterpret_cast<T*>(propMemory.get() + memOffset)) = value;
|
||||
propertiesChanged = true;
|
||||
}
|
||||
|
|
|
@ -59,6 +59,12 @@ namespace SHADE
|
|||
od.StoredDataOffset = lastInsertedData.StoredDataOffset + lastInsertedData.DataSize;
|
||||
}
|
||||
|
||||
// Size check
|
||||
if (od.StoredDataOffset + sizeof(T) > dataStoreSize)
|
||||
{
|
||||
throw std::runtime_error("Attempted to write to out of bounds MaterialInstance properties memory");
|
||||
}
|
||||
|
||||
// Save the override data information
|
||||
overrideData.emplace_back(std::move(od));
|
||||
existingOverride = overrideData.end() - 1;
|
||||
|
|
Loading…
Reference in New Issue