1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

villas/memory: add sanity check to deny allocating zero-sized memory

This commit is contained in:
Daniel Krebs 2018-07-20 16:50:54 +02:00
parent 8a06e96e92
commit 26abf44d2f

View file

@ -136,6 +136,12 @@ public:
MemoryAccessor<T>
allocate(size_t num)
{
if(num == 0) {
// doesn't make sense to allocate an empty block
logger->error("Trying to allocate empty memory");
throw std::bad_alloc();
}
const size_t size = num * sizeof(T);
auto mem = allocateBlock(size);