malloc can return NULL when given a 0 argument
This commit is contained in:
parent
046d5b38a9
commit
4b445d4860
|
@ -18,6 +18,6 @@ Malloc(sz)
|
|||
{
|
||||
register char *res = malloc(sz);
|
||||
|
||||
if (res == 0) No_Mem();
|
||||
if (sz && res == 0) No_Mem();
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue