malloc can return NULL when given a 0 argument

This commit is contained in:
ceriel 1989-10-30 18:25:30 +00:00
parent 046d5b38a9
commit 4b445d4860
3 changed files with 3 additions and 3 deletions

View file

@ -18,6 +18,6 @@ Malloc(sz)
{
register char *res = malloc(sz);
if (res == 0) No_Mem();
if (sz && res == 0) No_Mem();
return res;
}

View file

@ -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;
}

View file

@ -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;