From db66e4dc008c573957fd0bdee76c3f25eda4e17f Mon Sep 17 00:00:00 2001 From: geeksville Date: Sat, 13 Jun 2020 08:27:25 -0700 Subject: [PATCH] ensure we never get null from malloc --- src/mesh/MemoryPool.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mesh/MemoryPool.h b/src/mesh/MemoryPool.h index 8c6986e16..4fefb4c4d 100644 --- a/src/mesh/MemoryPool.h +++ b/src/mesh/MemoryPool.h @@ -65,9 +65,13 @@ template class MemoryDynamic : public Allocator } protected: - /// Return a queable object which has been prefilled with zeros - allow timeout to wait for available buffers (you - /// probably don't want this version). - virtual T *alloc(TickType_t maxWait) { return (T *)malloc(sizeof(T)); } + // Alloc some storage + virtual T *alloc(TickType_t maxWait) + { + T *p = (T *)malloc(sizeof(T)); + assert(p); + return p; + } }; /**