Date: Wed, 13 Jul 2016 14:59:17 +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: r302771 - head/usr.bin/mail Message-ID: <201607131459.u6DExH9T014006@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Wed Jul 13 14:59:17 2016 New Revision: 302771 URL: https://svnweb.freebsd.org/changeset/base/302771 Log: mail(1): check for out of memory conditions when calling calloc(3). Suggested by: oshogbo MFC after: 3 days Modified: head/usr.bin/mail/cmd3.c Modified: head/usr.bin/mail/cmd3.c ============================================================================== --- head/usr.bin/mail/cmd3.c Wed Jul 13 14:37:58 2016 (r302770) +++ head/usr.bin/mail/cmd3.c Wed Jul 13 14:59:17 2016 (r302771) @@ -463,7 +463,8 @@ group(char **argv) gname = *argv; h = hash(gname); if ((gh = findgroup(gname)) == NULL) { - gh = calloc(1, sizeof(*gh)); + if ((gh = calloc(1, sizeof(*gh))) == NULL) + err(1, "Out of memory"); gh->g_name = vcopy(gname); gh->g_list = NULL; gh->g_link = groups[h]; @@ -477,7 +478,8 @@ group(char **argv) */ for (ap = argv+1; *ap != NULL; ap++) { - gp = calloc(1, sizeof(*gp)); + if ((gp = calloc(1, sizeof(*gp))) == NULL) + err(1, "Out of memory"); gp->ge_name = vcopy(*ap); gp->ge_link = gh->g_list; gh->g_list = gp; @@ -702,7 +704,8 @@ alternates(char **namelist) } if (altnames != 0) (void)free(altnames); - altnames = calloc((unsigned)c, sizeof(char *)); + if ((altnames = calloc((unsigned)c, sizeof(char *))) == NULL) + err(1, "Out of memory"); for (ap = namelist, ap2 = altnames; *ap != NULL; ap++, ap2++) { cp = calloc((unsigned)strlen(*ap) + 1, sizeof(char)); strcpy(cp, *ap);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201607131459.u6DExH9T014006>