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);
|
register char *res = malloc(sz);
|
||||||
|
|
||||||
if (res == 0) No_Mem();
|
if (sz && res == 0) No_Mem();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,6 @@ Realloc(ptr, sz)
|
||||||
unsigned int sz;
|
unsigned int sz;
|
||||||
{
|
{
|
||||||
register char *mptr = realloc(ptr, sz);
|
register char *mptr = realloc(ptr, sz);
|
||||||
if (mptr == 0) No_Mem();
|
if (sz && mptr == 0) No_Mem();
|
||||||
return mptr;
|
return mptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ Salloc(str, sz)
|
||||||
char *res = malloc(sz);
|
char *res = malloc(sz);
|
||||||
register char *m = res;
|
register char *m = res;
|
||||||
|
|
||||||
if (m == 0) No_Mem();
|
if (sz && m == 0) No_Mem();
|
||||||
while (sz--)
|
while (sz--)
|
||||||
*m++ = *str++;
|
*m++ = *str++;
|
||||||
return res;
|
return res;
|
||||||
|
|
Loading…
Reference in a new issue