From 8a14afb7d5e87c5c1dfc05ae6b32587e7636d7f6 Mon Sep 17 00:00:00 2001 From: Chad Loder Date: Tue, 8 Mar 2005 03:05:08 +0000 Subject: Always check string allocation for failure. From Bruno Rohee, thanks. --- usr.bin/asn1_compile/gen.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/asn1_compile/gen.c b/usr.bin/asn1_compile/gen.c index 922d9317f08..2843f29be56 100644 --- a/usr.bin/asn1_compile/gen.c +++ b/usr.bin/asn1_compile/gen.c @@ -61,7 +61,7 @@ add_import (const char *module) { struct import *tmp = malloc (sizeof(*tmp)); if(tmp == NULL) - errx(1, "Out of memory"); + err(1, NULL); tmp->module = module; tmp->next = imports; @@ -79,8 +79,13 @@ init_generate (const char *filename, const char *base) { orig_filename = filename; if(base) - asprintf(&headerbase, "%s", base); + if((headerbase = strdup(base)) == NULL) + err(1, NULL); + asprintf(&header, "%s.h", headerbase); + if(header == NULL) + err(1, NULL); + headerfile = fopen (header, "w"); if (headerfile == NULL) err (1, "open %s", header); -- cgit v1.2.3