Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Jul 2016 15:09:09 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r302845 - head/usr.bin/mail
Message-ID:  <201607141509.u6EF99K6054797@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Thu Jul 14 15:09:08 2016
New Revision: 302845
URL: https://svnweb.freebsd.org/changeset/base/302845

Log:
  mail(1): check for out of memory conditions when calling calloc(3).
  
  X-MFC with:	r302771

Modified:
  head/usr.bin/mail/vars.c

Modified: head/usr.bin/mail/vars.c
==============================================================================
--- head/usr.bin/mail/vars.c	Thu Jul 14 14:48:40 2016	(r302844)
+++ head/usr.bin/mail/vars.c	Thu Jul 14 15:09:08 2016	(r302845)
@@ -56,7 +56,8 @@ assign(const char *name, const char *val
 	h = hash(name);
 	vp = lookup(name);
 	if (vp == NULL) {
-		vp = calloc(1, sizeof(*vp));
+		if ((vp = calloc(1, sizeof(*vp))) == NULL)
+			err(1, "Out of memory");
 		vp->v_name = vcopy(name);
 		vp->v_link = variables[h];
 		variables[h] = vp;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607141509.u6EF99K6054797>