In vcopy(), check the return value of calloc() and panic when
authorCarl Smith <carl@ucbvax.Berkeley.EDU>
Thu, 21 Oct 1982 20:41:22 +0000 (12:41 -0800)
committerCarl Smith <carl@ucbvax.Berkeley.EDU>
Thu, 21 Oct 1982 20:41:22 +0000 (12:41 -0800)
one runs out of core.

SCCS-vsn: usr.bin/mail/vars.c 2.3

usr/src/usr.bin/mail/vars.c

index 7f07f93..6455a17 100644 (file)
@@ -8,7 +8,7 @@
  * Variable handling stuff.
  */
 
  * Variable handling stuff.
  */
 
-static char *SccsId = "@(#)vars.c      2.2 %G%";
+static char *SccsId = "@(#)vars.c      2.3 %G%";
 
 /*
  * Assign a value to a variable.
 
 /*
  * Assign a value to a variable.
@@ -59,7 +59,8 @@ vcopy(str)
 
        if (equal(str, ""))
                return("");
 
        if (equal(str, ""))
                return("");
-       top = calloc(strlen(str)+1, 1);
+       if ((top = calloc(strlen(str)+1, 1)) == NULL)
+               panic ("Out of memory");
        cp = top;
        cp2 = str;
        while (*cp++ = *cp2++)
        cp = top;
        cp2 = str;
        while (*cp++ = *cp2++)