From 4b445d48603945e1f0d95a00d3ef836acb3db344 Mon Sep 17 00:00:00 2001 From: ceriel Date: Mon, 30 Oct 1989 18:25:30 +0000 Subject: [PATCH] malloc can return NULL when given a 0 argument --- modules/src/alloc/Malloc.c | 2 +- modules/src/alloc/Realloc.c | 2 +- modules/src/alloc/Salloc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/src/alloc/Malloc.c b/modules/src/alloc/Malloc.c index fa28074d9..29951d013 100644 --- a/modules/src/alloc/Malloc.c +++ b/modules/src/alloc/Malloc.c @@ -18,6 +18,6 @@ Malloc(sz) { register char *res = malloc(sz); - if (res == 0) No_Mem(); + if (sz && res == 0) No_Mem(); return res; } diff --git a/modules/src/alloc/Realloc.c b/modules/src/alloc/Realloc.c index 7d2ff7f5f..527b5268e 100644 --- a/modules/src/alloc/Realloc.c +++ b/modules/src/alloc/Realloc.c @@ -18,6 +18,6 @@ Realloc(ptr, sz) unsigned int sz; { register char *mptr = realloc(ptr, sz); - if (mptr == 0) No_Mem(); + if (sz && mptr == 0) No_Mem(); return mptr; } diff --git a/modules/src/alloc/Salloc.c b/modules/src/alloc/Salloc.c index 2773360b7..4d16045c2 100644 --- a/modules/src/alloc/Salloc.c +++ b/modules/src/alloc/Salloc.c @@ -24,7 +24,7 @@ Salloc(str, sz) char *res = malloc(sz); register char *m = res; - if (m == 0) No_Mem(); + if (sz && m == 0) No_Mem(); while (sz--) *m++ = *str++; return res;