summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjaredy <jaredy@openbsd.org>2005-05-11 19:45:50 +0000
committerjaredy <jaredy@openbsd.org>2005-05-11 19:45:50 +0000
commit4406cf4cc7b2ce3d90a16154d4f8f55c57c7666a (patch)
treeb91570d2c65b1a3f716b4f126fc5f18c71000d8e
parentReset IO completion values to 0 to disable completion holdof. This improves (diff)
downloadwireguard-openbsd-4406cf4cc7b2ce3d90a16154d4f8f55c57c7666a.tar.xz
wireguard-openbsd-4406cf4cc7b2ce3d90a16154d4f8f55c57c7666a.zip
allocation failure checks; ok otto, moritz
-rw-r--r--usr.bin/asn1_compile/gen.c3
-rw-r--r--usr.bin/asn1_compile/hash.c4
-rw-r--r--usr.bin/asn1_compile/symbol.c5
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);