Commit d3a58196 authored by Daniel Krebs's avatar Daniel Krebs
Browse files

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

parent 26d7a13e
Pipeline #64229 failed with stages
in 1 minute and 11 seconds
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment