Create a null element and return it

This commit is contained in:
Alex
2023-02-26 10:56:11 +02:00
parent 5427e7f2ca
commit 7b756263c0
2 changed files with 18 additions and 2 deletions

View File

@ -149,7 +149,16 @@ public:
VectorSize = Size;
}
__no_instrument_function T &operator[](size_t Index) { return VectorBuffer[Index]; }
__no_instrument_function T &operator[](size_t Index)
{
if (!reinterpret_cast<uintptr_t>(&VectorBuffer[Index]))
{
warn("operator[]( %lld ) is null (requested by %#lx)", Index, __builtin_return_address(0));
static T null_elem;
return null_elem;
}
return VectorBuffer[Index];
}
__no_instrument_function Vector<T> &operator=(const Vector<T> &Vector)
{