fix: V-001 security vulnerability
Automated security fix generated by OrbisAI Security
This commit is contained in:
parent
58e13d16a5
commit
83ba5bbf00
|
|
@ -94,6 +94,7 @@ class Arena {
|
||||||
template <class T>
|
template <class T>
|
||||||
inline T* Allocate(size_t n) {
|
inline T* Allocate(size_t n) {
|
||||||
static_assert(!std::is_reference<T>(), "");
|
static_assert(!std::is_reference<T>(), "");
|
||||||
|
if (n > std::numeric_limits<size_t>::max() / sizeof(T)) throw std::bad_alloc();
|
||||||
return static_cast<T*>(Allocate(n * sizeof(T), alignof(T)));
|
return static_cast<T*>(Allocate(n * sizeof(T), alignof(T)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue