malloc can return NULL when given a 0 argument
authorceriel <none@none>
Mon, 30 Oct 1989 18:25:30 +0000 (18:25 +0000)
committerceriel <none@none>
Mon, 30 Oct 1989 18:25:30 +0000 (18:25 +0000)
modules/src/alloc/Malloc.c
modules/src/alloc/Realloc.c
modules/src/alloc/Salloc.c

index fa28074..29951d0 100644 (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;
 }
index 7d2ff7f..527b526 100644 (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;
 }
index 2773360..4d16045 100644 (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;