summaryrefslogtreecommitdiff
path: root/lib/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/memory.c')
-rw-r--r--lib/memory.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/memory.c b/lib/memory.c
index be8b100ba7..318c381bf5 100644
--- a/lib/memory.c
+++ b/lib/memory.c
@@ -52,7 +52,10 @@ static inline void mt_count_free(struct memtype *mt)
static inline void *mt_checkalloc(struct memtype *mt, void *ptr, size_t size)
{
if (__builtin_expect(ptr == NULL, 0)) {
- memory_oom(size, mt->name);
+ if (size) {
+ /* malloc(0) is allowed to return NULL */
+ memory_oom(size, mt->name);
+ }
return NULL;
}
mt_count_alloc(mt, size);