diff options
author | Jared Yanovich <jaredy@cvs.openbsd.org> | 2005-05-11 19:45:51 +0000 |
---|---|---|
committer | Jared Yanovich <jaredy@cvs.openbsd.org> | 2005-05-11 19:45:51 +0000 |
commit | bf0fb0dd24dc15dea7cfa018aac1ca44c8aab984 (patch) | |
tree | 20b97ea4f99e7ce6d87eff43df7c10c5eeacc31e | |
parent | da5aa746a14ecbe5b33033f82aeb9a5db51432f2 (diff) |
allocation failure checks; ok otto, moritz
-rw-r--r-- | usr.bin/asn1_compile/gen.c | 3 | ||||
-rw-r--r-- | usr.bin/asn1_compile/hash.c | 4 | ||||
-rw-r--r-- | usr.bin/asn1_compile/symbol.c | 5 |
3 files changed, 8 insertions, 4 deletions
diff --git a/usr.bin/asn1_compile/gen.c b/usr.bin/asn1_compile/gen.c index 2843f29be56..929686bc838 100644 --- a/usr.bin/asn1_compile/gen.c +++ b/usr.bin/asn1_compile/gen.c @@ -430,7 +430,8 @@ generate_type (const Symbol *s) struct import *i; char *filename; - asprintf (&filename, "%s_%s.x", STEM, s->gen_name); + if (asprintf (&filename, "%s_%s.x", STEM, s->gen_name) == -1) + err (1, NULL); codefile = fopen (filename, "w"); if (codefile == NULL) err (1, "fopen %s", filename); diff --git a/usr.bin/asn1_compile/hash.c b/usr.bin/asn1_compile/hash.c index 80ad0f6f66a..8f954615e71 100644 --- a/usr.bin/asn1_compile/hash.c +++ b/usr.bin/asn1_compile/hash.c @@ -55,12 +55,12 @@ hashtabnew(int sz, assert(sz > 0); htab = (Hashtab *) malloc(sizeof(Hashtab) + (sz - 1) * sizeof(Hashentry *)); - for (i = 0; i < sz; ++i) - htab->tab[i] = NULL; if (htab == NULL) { return NULL; } else { + for (i = 0; i < sz; ++i) + htab->tab[i] = NULL; htab->cmp = cmp; htab->hash = hash; htab->sz = sz; diff --git a/usr.bin/asn1_compile/symbol.c b/usr.bin/asn1_compile/symbol.c index 1be1dfd544f..7b429a8bdeb 100644 --- a/usr.bin/asn1_compile/symbol.c +++ b/usr.bin/asn1_compile/symbol.c @@ -82,8 +82,11 @@ addsym (char *name) s = (Symbol *)hashtabsearch (htab, (void *)&key); if (s == NULL) { s = (Symbol *)malloc (sizeof (*s)); + if (s == NULL) + err(1, NULL); s->name = name; - s->gen_name = strdup(name); + if ((s->gen_name = strdup(name)) == NULL) + err(1, NULL); output_name (s->gen_name); s->stype = SUndefined; hashtabadd (htab, s); |