There are a number of corner cases that aren't properly dealt with in config(1) when memory allocations fail. There may be issues with memory leaks in config(1), but this is outside of the scope of this patch. Fix: See attached patch. Patch attached with submission follows:
The attached patch addresses the non-style(9) conformity with my previous patch as pointed out by several folks on current@. Thanks, -Garrett
On Fri, Mar 12, 2010 at 11:28 PM, Garrett Cooper <yaneurabeya@gmail.com> wrote: > The attached patch addresses the non-style(9) conformity with my > previous patch as pointed out by several folks on current@. Sorry -- missed a spot... Thanks, -Garrett
On Sat, Mar 13, 2010 at 12:36 AM, Garrett Cooper <yaneurabeya@gmail.com> wrote: > On Fri, Mar 12, 2010 at 11:28 PM, Garrett Cooper <yaneurabeya@gmail.com> wrote: >> The attached patch addresses the non-style(9) conformity with my >> previous patch as pointed out by several folks on current@. > > Sorry -- missed a spot... The following patch incorporates a logical change from errx(3) to err(3) made by ru@ in an informal review. I also picked up a few other logical messages that were originally errx(EXIT_ERR, ...) and converted them to err(EXIT_ERR, ...) in a similar fashion. Thanks, -Garrett
On Sun, Mar 21, 2010 at 04:58:18AM -0700, Garrett Cooper wrote: > On Sat, Mar 13, 2010 at 12:36 AM, Garrett Cooper <yaneurabeya@gmail.com> wrote: > > On Fri, Mar 12, 2010 at 11:28 PM, Garrett Cooper <yaneurabeya@gmail.com> wrote: > >> The attached patch addresses the non-style(9) conformity with my > >> previous patch as pointed out by several folks on current@. > > > > Sorry -- missed a spot... > > The following patch incorporates a logical change from errx(3) to > err(3) made by ru@ in an informal review. I also picked up a few other > logical messages that were originally errx(EXIT_ERR, ...) and > converted them to err(EXIT_ERR, ...) in a similar fashion. Part of the changes are invalid (shouldn't have been converted from errx() to err()). : Index: main.c : =================================================================== : --- main.c (revision 205872) : +++ main.c (working copy) : @@ -120,7 +120,7 @@ : if (*destdir == '\0') : strlcpy(destdir, optarg, sizeof(destdir)); : else : - errx(2, "directory already set"); : + err(EXIT_FAILURE, "directory already set"); : break; : case 'g': : debugging++; : @@ -175,7 +175,7 @@ : if (mkdir(p, 0777)) : err(2, "%s", p); : } else if (!S_ISDIR(buf.st_mode)) : - errx(2, "%s isn't a directory", p); : + err(EXIT_FAILURE, "%s isn't a directory", p); : : SLIST_INIT(&cputype); : SLIST_INIT(&mkopt); : @@ -519,7 +519,7 @@ : */ : p = strstr(kernconfstr, KERNCONFTAG); : if (p == NULL) : - errx(EXIT_FAILURE, "Something went terribly wrong!"); : + err(EXIT_FAILURE, "Something went terribly wrong!"); : *p = '\0'; : fprintf(fo, "%s", kernconfstr); : fprintf(fo, "%s", sbuf_data(sb)); : @@ -671,19 +673,19 @@ : [...] : if (S_ISDIR(st.st_mode)) : - errx(EXIT_FAILURE, "'%s' is a directory", file); : + err(EXIT_FAILURE, "'%s' is a directory", file); : fp = fdopen(r, "r"); : [...] : pp = popen(cmd, "r"); : if (pp == NULL) : - errx(EXIT_FAILURE, "popen() failed"); : + err(EXIT_FAILURE, "popen() failed"); This is questionable; see the popen(3) manpage for details, section ERRORS. : Index: lang.l : =================================================================== : --- lang.l (revision 205872) : +++ lang.l (working copy) : @@ -31,6 +31,7 @@ : * $FreeBSD$ : */ : : +#include <err.h> Misplaced include. : #include <assert.h> : #include <ctype.h> : #include <string.h> Cheers, -- Ruslan Ermilov ru@FreeBSD.org FreeBSD committer
On Tue, Mar 30, 2010 at 3:34 AM, Ruslan Ermilov <ru@freebsd.org> wrote: > On Sun, Mar 21, 2010 at 04:58:18AM -0700, Garrett Cooper wrote: >> On Sat, Mar 13, 2010 at 12:36 AM, Garrett Cooper <yaneurabeya@gmail.com> wrote: >> > On Fri, Mar 12, 2010 at 11:28 PM, Garrett Cooper <yaneurabeya@gmail.com> wrote: >> >> The attached patch addresses the non-style(9) conformity with my >> >> previous patch as pointed out by several folks on current@. >> > >> > Sorry -- missed a spot... >> >> The following patch incorporates a logical change from errx(3) to >> err(3) made by ru@ in an informal review. I also picked up a few other >> logical messages that were originally errx(EXIT_ERR, ...) and >> converted them to err(EXIT_ERR, ...) in a similar fashion. > > Part of the changes are invalid (shouldn't have been converted from > errx() to err()). > > : Index: main.c > : =================================================================== > : --- main.c (revision 205872) > : +++ main.c (working copy) > : @@ -120,7 +120,7 @@ > : if (*destdir == '\0') > : strlcpy(destdir, optarg, sizeof(destdir)); > : else > : - errx(2, "directory already set"); > : + err(EXIT_FAILURE, "directory already set"); > : break; > : case 'g': > : debugging++; > : @@ -175,7 +175,7 @@ > : if (mkdir(p, 0777)) > : err(2, "%s", p); > : } else if (!S_ISDIR(buf.st_mode)) > : - errx(2, "%s isn't a directory", p); > : + err(EXIT_FAILURE, "%s isn't a directory", p); > : > : SLIST_INIT(&cputype); > : SLIST_INIT(&mkopt); > : @@ -519,7 +519,7 @@ > : */ > : p = strstr(kernconfstr, KERNCONFTAG); > : if (p == NULL) > : - errx(EXIT_FAILURE, "Something went terribly wrong!"); > : + err(EXIT_FAILURE, "Something went terribly wrong!"); > : *p = '\0'; > : fprintf(fo, "%s", kernconfstr); > : fprintf(fo, "%s", sbuf_data(sb)); > : @@ -671,19 +673,19 @@ > : [...] > : if (S_ISDIR(st.st_mode)) > : - errx(EXIT_FAILURE, "'%s' is a directory", file); > : + err(EXIT_FAILURE, "'%s' is a directory", file); > : fp = fdopen(r, "r"); > : [...] > : pp = popen(cmd, "r"); > : if (pp == NULL) > : - errx(EXIT_FAILURE, "popen() failed"); > : + err(EXIT_FAILURE, "popen() failed"); > > This is questionable; see the popen(3) manpage for details, > section ERRORS. > > : Index: lang.l > : =================================================================== > : --- lang.l (revision 205872) > : +++ lang.l (working copy) > : @@ -31,6 +31,7 @@ > : * $FreeBSD$ > : */ > : > : +#include <err.h> > > Misplaced include. > > : #include <assert.h> > : #include <ctype.h> > : #include <string.h> Hi Ruslan! Thanks for the review! This should resolve all of the issues you spotted before, as well as fixes a typo in a comment near one of the changes that I spotted before. Cheers, -Garrett
Author: ru Date: Tue Mar 30 13:46:40 2010 New Revision: 205880 URL: http://svn.freebsd.org/changeset/base/205880 Log: - Handle calloc() allocation failures. - Fixed a comment. - 2 -> EXIT_FAILURE in some places. - errx() -> err() where appropriate. PR: 144644 Submitted by: Garrett Cooper Modified: head/usr.sbin/config/config.y head/usr.sbin/config/lang.l head/usr.sbin/config/main.c head/usr.sbin/config/mkmakefile.c head/usr.sbin/config/mkoptions.c Modified: head/usr.sbin/config/config.y ============================================================================== --- head/usr.sbin/config/config.y Tue Mar 30 12:08:00 2010 (r205879) +++ head/usr.sbin/config/config.y Tue Mar 30 13:46:40 2010 (r205880) @@ -166,6 +166,8 @@ Config_spec: CPU Save_id { struct cputype *cp = (struct cputype *)calloc(1, sizeof (struct cputype)); + if (cp == NULL) + err(EXIT_FAILURE, "calloc"); cp->cpu_name = $2; SLIST_INSERT_HEAD(&cputype, cp, cpu_next); } | @@ -197,6 +199,8 @@ Config_spec: struct hint *hint; hint = (struct hint *)calloc(1, sizeof (struct hint)); + if (hint == NULL) + err(EXIT_FAILURE, "calloc"); hint->hint_name = $2; STAILQ_INSERT_TAIL(&hints, hint, hint_next); hintmode = 1; @@ -331,6 +335,8 @@ newfile(char *name) struct files_name *nl; nl = (struct files_name *) calloc(1, sizeof *nl); + if (nl == NULL) + err(EXIT_FAILURE, "calloc"); nl->f_name = name; STAILQ_INSERT_TAIL(&fntab, nl, f_next); } @@ -364,6 +370,8 @@ newdev(char *name) } np = (struct device *) calloc(1, sizeof *np); + if (np == NULL) + err(EXIT_FAILURE, "calloc"); np->d_name = name; STAILQ_INSERT_TAIL(&dtab, np, d_next); } @@ -422,6 +430,8 @@ newopt(struct opt_head *list, char *name } op = (struct opt *)calloc(1, sizeof (struct opt)); + if (op == NULL) + err(EXIT_FAILURE, "calloc"); op->op_name = name; op->op_ownfile = 0; op->op_value = value; Modified: head/usr.sbin/config/lang.l ============================================================================== --- head/usr.sbin/config/lang.l Tue Mar 30 12:08:00 2010 (r205879) +++ head/usr.sbin/config/lang.l Tue Mar 30 13:46:40 2010 (r205880) @@ -33,6 +33,7 @@ #include <assert.h> #include <ctype.h> +#include <err.h> #include <string.h> #include "y.tab.h" #include "config.h" @@ -220,6 +221,8 @@ cfgfile_add(const char *fname) struct cfgfile *cf; cf = calloc(1, sizeof(*cf)); + if (cf == NULL) + err(EXIT_FAILURE, "calloc"); assert(cf != NULL); asprintf(&cf->cfg_path, "%s", fname); STAILQ_INSERT_TAIL(&cfgfiles, cf, cfg_next); Modified: head/usr.sbin/config/main.c ============================================================================== --- head/usr.sbin/config/main.c Tue Mar 30 12:08:00 2010 (r205879) +++ head/usr.sbin/config/main.c Tue Mar 30 13:46:40 2010 (r205880) @@ -120,7 +120,7 @@ main(int argc, char **argv) if (*destdir == '\0') strlcpy(destdir, optarg, sizeof(destdir)); else - errx(2, "directory already set"); + errx(EXIT_FAILURE, "directory already set"); break; case 'g': debugging++; @@ -175,7 +175,7 @@ main(int argc, char **argv) if (mkdir(p, 0777)) err(2, "%s", p); } else if (!S_ISDIR(buf.st_mode)) - errx(2, "%s isn't a directory", p); + errx(EXIT_FAILURE, "%s isn't a directory", p); SLIST_INIT(&cputype); SLIST_INIT(&mkopt); @@ -256,7 +256,7 @@ get_srcdir(void) int i; if (realpath("../..", srcdir) == NULL) - errx(2, "Unable to find root of source tree"); + err(EXIT_FAILURE, "Unable to find root of source tree"); if ((pwd = getenv("PWD")) != NULL && *pwd == '/' && (pwd = strdup(pwd)) != NULL) { /* Remove the last two path components. */ @@ -513,7 +513,7 @@ configfile(void) } sbuf_finish(sb); /* - * We print first part of the tamplate, replace our tag with + * We print first part of the template, replace our tag with * configuration files content and later continue writing our * template. */ @@ -650,6 +650,8 @@ remember(const char *file) } } hl = calloc(1, sizeof(*hl)); + if (hl == NULL) + err(EXIT_FAILURE, "calloc"); hl->h_name = s; hl->h_next = htab; htab = hl; @@ -671,19 +673,19 @@ kernconfdump(const char *file) r = open(file, O_RDONLY); if (r == -1) - errx(EXIT_FAILURE, "Couldn't open file '%s'", file); + err(EXIT_FAILURE, "Couldn't open file '%s'", file); error = fstat(r, &st); if (error == -1) - errx(EXIT_FAILURE, "fstat() failed"); + err(EXIT_FAILURE, "fstat() failed"); if (S_ISDIR(st.st_mode)) errx(EXIT_FAILURE, "'%s' is a directory", file); fp = fdopen(r, "r"); if (fp == NULL) - errx(EXIT_FAILURE, "fdopen() failed"); + err(EXIT_FAILURE, "fdopen() failed"); osz = 1024; o = calloc(1, osz); if (o == NULL) - errx(EXIT_FAILURE, "Couldn't allocate memory"); + err(EXIT_FAILURE, "Couldn't allocate memory"); /* ELF note section header. */ asprintf(&cmd, "/usr/bin/elfdump -c %s | grep -A 5 kern_conf" "| tail -2 | cut -d ' ' -f 2 | paste - - -", file); @@ -703,7 +705,7 @@ kernconfdump(const char *file) "INCLUDE_CONFIG_FILE", file); r = fseek(fp, off, SEEK_CUR); if (r != 0) - errx(EXIT_FAILURE, "fseek() failed"); + err(EXIT_FAILURE, "fseek() failed"); for (i = 0; i < size - 1; i++) { r = fgetc(fp); if (r == EOF) Modified: head/usr.sbin/config/mkmakefile.c ============================================================================== --- head/usr.sbin/config/mkmakefile.c Tue Mar 30 12:08:00 2010 (r205879) +++ head/usr.sbin/config/mkmakefile.c Tue Mar 30 13:46:40 2010 (r205880) @@ -98,6 +98,8 @@ new_fent(void) struct file_list *fp; fp = (struct file_list *) calloc(1, sizeof *fp); + if (fp == NULL) + err(EXIT_FAILURE, "calloc"); STAILQ_INSERT_TAIL(&ftab, fp, f_next); return (fp); } Modified: head/usr.sbin/config/mkoptions.c ============================================================================== --- head/usr.sbin/config/mkoptions.c Tue Mar 30 12:08:00 2010 (r205879) +++ head/usr.sbin/config/mkoptions.c Tue Mar 30 13:46:40 2010 (r205880) @@ -70,6 +70,8 @@ options(void) /* Fake the cpu types as options. */ SLIST_FOREACH(cp, &cputype, cpu_next) { op = (struct opt *)calloc(1, sizeof(*op)); + if (op == NULL) + err(EXIT_FAILURE, "calloc"); op->op_name = ns(cp->cpu_name); SLIST_INSERT_HEAD(&opt, op, op_next); } @@ -84,6 +86,8 @@ options(void) /* Fake MAXUSERS as an option. */ op = (struct opt *)calloc(1, sizeof(*op)); + if (op == NULL) + err(EXIT_FAILURE, "calloc"); op->op_name = ns("MAXUSERS"); snprintf(buf, sizeof(buf), "%d", maxusers); op->op_value = ns(buf); @@ -199,6 +203,8 @@ do_option(char *name) tidy++; } else { op = (struct opt *) calloc(1, sizeof *op); + if (op == NULL) + err(EXIT_FAILURE, "calloc"); op->op_name = inw; op->op_value = invalue; SLIST_INSERT_HEAD(&op_head, op, op_next); @@ -225,6 +231,8 @@ do_option(char *name) if (value && !seen) { /* New option appears */ op = (struct opt *) calloc(1, sizeof *op); + if (op == NULL) + err(EXIT_FAILURE, "calloc"); op->op_name = ns(name); op->op_value = value ? ns(value) : NULL; SLIST_INSERT_HEAD(&op_head, op, op_next); @@ -336,6 +344,8 @@ next: } po = (struct opt_list *) calloc(1, sizeof *po); + if (po == NULL) + err(EXIT_FAILURE, "calloc"); po->o_name = this; po->o_file = val; SLIST_INSERT_HEAD(&otab, po, o_next); _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
State Changed From-To: open->closed Patch committed to HEAD.
Author: emaste Date: Tue Apr 13 18:46:18 2010 New Revision: 206559 URL: http://svn.freebsd.org/changeset/base/206559 Log: MFC r205880 by ru: - Handle calloc() allocation failures. - Fixed a comment. - 2 -> EXIT_FAILURE in some places. - errx() -> err() where appropriate. PR: 144644 Submitted by: Garrett Cooper Also fix endinclude() prototype to avoid compiler warning. Modified: stable/8/usr.sbin/config/config.y stable/8/usr.sbin/config/lang.l stable/8/usr.sbin/config/main.c stable/8/usr.sbin/config/mkmakefile.c stable/8/usr.sbin/config/mkoptions.c Directory Properties: stable/8/usr.sbin/config/ (props changed) Modified: stable/8/usr.sbin/config/config.y ============================================================================== --- stable/8/usr.sbin/config/config.y Tue Apr 13 15:55:18 2010 (r206558) +++ stable/8/usr.sbin/config/config.y Tue Apr 13 18:46:18 2010 (r206559) @@ -166,6 +166,8 @@ Config_spec: CPU Save_id { struct cputype *cp = (struct cputype *)calloc(1, sizeof (struct cputype)); + if (cp == NULL) + err(EXIT_FAILURE, "calloc"); cp->cpu_name = $2; SLIST_INSERT_HEAD(&cputype, cp, cpu_next); } | @@ -197,6 +199,8 @@ Config_spec: struct hint *hint; hint = (struct hint *)calloc(1, sizeof (struct hint)); + if (hint == NULL) + err(EXIT_FAILURE, "calloc"); hint->hint_name = $2; STAILQ_INSERT_TAIL(&hints, hint, hint_next); hintmode = 1; @@ -331,6 +335,8 @@ newfile(char *name) struct files_name *nl; nl = (struct files_name *) calloc(1, sizeof *nl); + if (nl == NULL) + err(EXIT_FAILURE, "calloc"); nl->f_name = name; STAILQ_INSERT_TAIL(&fntab, nl, f_next); } @@ -364,6 +370,8 @@ newdev(char *name) } np = (struct device *) calloc(1, sizeof *np); + if (np == NULL) + err(EXIT_FAILURE, "calloc"); np->d_name = name; STAILQ_INSERT_TAIL(&dtab, np, d_next); } @@ -422,6 +430,8 @@ newopt(struct opt_head *list, char *name } op = (struct opt *)calloc(1, sizeof (struct opt)); + if (op == NULL) + err(EXIT_FAILURE, "calloc"); op->op_name = name; op->op_ownfile = 0; op->op_value = value; Modified: stable/8/usr.sbin/config/lang.l ============================================================================== --- stable/8/usr.sbin/config/lang.l Tue Apr 13 15:55:18 2010 (r206558) +++ stable/8/usr.sbin/config/lang.l Tue Apr 13 18:46:18 2010 (r206559) @@ -33,6 +33,7 @@ #include <assert.h> #include <ctype.h> +#include <err.h> #include <string.h> #include "y.tab.h" #include "config.h" @@ -220,6 +221,8 @@ cfgfile_add(const char *fname) struct cfgfile *cf; cf = calloc(1, sizeof(*cf)); + if (cf == NULL) + err(EXIT_FAILURE, "calloc"); assert(cf != NULL); asprintf(&cf->cfg_path, "%s", fname); STAILQ_INSERT_TAIL(&cfgfiles, cf, cfg_next); @@ -285,7 +288,7 @@ include(const char *fname, int ateof) * Terminate the most recent inclusion. */ static int -endinclude() +endinclude(void) { struct incl *in; int ateof; Modified: stable/8/usr.sbin/config/main.c ============================================================================== --- stable/8/usr.sbin/config/main.c Tue Apr 13 15:55:18 2010 (r206558) +++ stable/8/usr.sbin/config/main.c Tue Apr 13 18:46:18 2010 (r206559) @@ -120,7 +120,7 @@ main(int argc, char **argv) if (*destdir == '\0') strlcpy(destdir, optarg, sizeof(destdir)); else - errx(2, "directory already set"); + errx(EXIT_FAILURE, "directory already set"); break; case 'g': debugging++; @@ -175,7 +175,7 @@ main(int argc, char **argv) if (mkdir(p, 0777)) err(2, "%s", p); } else if (!S_ISDIR(buf.st_mode)) - errx(2, "%s isn't a directory", p); + errx(EXIT_FAILURE, "%s isn't a directory", p); SLIST_INIT(&cputype); SLIST_INIT(&mkopt); @@ -256,7 +256,7 @@ get_srcdir(void) int i; if (realpath("../..", srcdir) == NULL) - errx(2, "Unable to find root of source tree"); + err(EXIT_FAILURE, "Unable to find root of source tree"); if ((pwd = getenv("PWD")) != NULL && *pwd == '/' && (pwd = strdup(pwd)) != NULL) { /* Remove the last two path components. */ @@ -513,7 +513,7 @@ configfile(void) } sbuf_finish(sb); /* - * We print first part of the tamplate, replace our tag with + * We print first part of the template, replace our tag with * configuration files content and later continue writing our * template. */ @@ -650,6 +650,8 @@ remember(const char *file) } } hl = calloc(1, sizeof(*hl)); + if (hl == NULL) + err(EXIT_FAILURE, "calloc"); hl->h_name = s; hl->h_next = htab; htab = hl; @@ -671,19 +673,19 @@ kernconfdump(const char *file) r = open(file, O_RDONLY); if (r == -1) - errx(EXIT_FAILURE, "Couldn't open file '%s'", file); + err(EXIT_FAILURE, "Couldn't open file '%s'", file); error = fstat(r, &st); if (error == -1) - errx(EXIT_FAILURE, "fstat() failed"); + err(EXIT_FAILURE, "fstat() failed"); if (S_ISDIR(st.st_mode)) errx(EXIT_FAILURE, "'%s' is a directory", file); fp = fdopen(r, "r"); if (fp == NULL) - errx(EXIT_FAILURE, "fdopen() failed"); + err(EXIT_FAILURE, "fdopen() failed"); osz = 1024; o = calloc(1, osz); if (o == NULL) - errx(EXIT_FAILURE, "Couldn't allocate memory"); + err(EXIT_FAILURE, "Couldn't allocate memory"); /* ELF note section header. */ asprintf(&cmd, "/usr/bin/elfdump -c %s | grep -A 5 kern_conf" "| tail -2 | cut -d ' ' -f 2 | paste - - -", file); @@ -703,7 +705,7 @@ kernconfdump(const char *file) "INCLUDE_CONFIG_FILE", file); r = fseek(fp, off, SEEK_CUR); if (r != 0) - errx(EXIT_FAILURE, "fseek() failed"); + err(EXIT_FAILURE, "fseek() failed"); for (i = 0; i < size - 1; i++) { r = fgetc(fp); if (r == EOF) Modified: stable/8/usr.sbin/config/mkmakefile.c ============================================================================== --- stable/8/usr.sbin/config/mkmakefile.c Tue Apr 13 15:55:18 2010 (r206558) +++ stable/8/usr.sbin/config/mkmakefile.c Tue Apr 13 18:46:18 2010 (r206559) @@ -98,6 +98,8 @@ new_fent(void) struct file_list *fp; fp = (struct file_list *) calloc(1, sizeof *fp); + if (fp == NULL) + err(EXIT_FAILURE, "calloc"); STAILQ_INSERT_TAIL(&ftab, fp, f_next); return (fp); } Modified: stable/8/usr.sbin/config/mkoptions.c ============================================================================== --- stable/8/usr.sbin/config/mkoptions.c Tue Apr 13 15:55:18 2010 (r206558) +++ stable/8/usr.sbin/config/mkoptions.c Tue Apr 13 18:46:18 2010 (r206559) @@ -70,6 +70,8 @@ options(void) /* Fake the cpu types as options. */ SLIST_FOREACH(cp, &cputype, cpu_next) { op = (struct opt *)calloc(1, sizeof(*op)); + if (op == NULL) + err(EXIT_FAILURE, "calloc"); op->op_name = ns(cp->cpu_name); SLIST_INSERT_HEAD(&opt, op, op_next); } @@ -84,6 +86,8 @@ options(void) /* Fake MAXUSERS as an option. */ op = (struct opt *)calloc(1, sizeof(*op)); + if (op == NULL) + err(EXIT_FAILURE, "calloc"); op->op_name = ns("MAXUSERS"); snprintf(buf, sizeof(buf), "%d", maxusers); op->op_value = ns(buf); @@ -199,6 +203,8 @@ do_option(char *name) tidy++; } else { op = (struct opt *) calloc(1, sizeof *op); + if (op == NULL) + err(EXIT_FAILURE, "calloc"); op->op_name = inw; op->op_value = invalue; SLIST_INSERT_HEAD(&op_head, op, op_next); @@ -225,6 +231,8 @@ do_option(char *name) if (value && !seen) { /* New option appears */ op = (struct opt *) calloc(1, sizeof *op); + if (op == NULL) + err(EXIT_FAILURE, "calloc"); op->op_name = ns(name); op->op_value = value ? ns(value) : NULL; SLIST_INSERT_HEAD(&op_head, op, op_next); @@ -336,6 +344,8 @@ next: } po = (struct opt_list *) calloc(1, sizeof *po); + if (po == NULL) + err(EXIT_FAILURE, "calloc"); po->o_name = this; po->o_file = val; SLIST_INSERT_HEAD(&otab, po, o_next); _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"