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:
parent
8a06e96e92
commit
26abf44d2f
1 changed files with 6 additions and 0 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue