diff --git a/modules/src/malloc/mal.c b/modules/src/malloc/mal.c index 29ad660f5..253c7e581 100644 --- a/modules/src/malloc/mal.c +++ b/modules/src/malloc/mal.c @@ -39,6 +39,9 @@ malloc(n) register mallink *ml; register int min_class; + if (n == 0) { + return 0; + } if (n < MIN_SIZE) n = align(MIN_SIZE); else n = align(n); #ifdef STORE if (n <= MAX_STORE*MIN_SIZE) { @@ -234,6 +237,10 @@ realloc(addr, n) */ return malloc(n); } + if (n == 0) { + free(addr); + return 0; + } ml = mallink_of_block(addr); if (n < MIN_SIZE) n = align(MIN_SIZE); else n = align(n); #ifdef STORE