mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 12:49:18 +00:00
lib: make allocators work for allocation sizes of 0
Fixes: #2155 Signed-off-by: Christian Franke <chris@opensourcerouting.org>
This commit is contained in:
parent
bdb53116de
commit
c897c456d7
@ -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)
|
static inline void *mt_checkalloc(struct memtype *mt, void *ptr, size_t size)
|
||||||
{
|
{
|
||||||
if (__builtin_expect(ptr == NULL, 0)) {
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
mt_count_alloc(mt, size);
|
mt_count_alloc(mt, size);
|
||||||
|
Loading…
Reference in New Issue
Block a user