summaryrefslogtreecommitdiff
path: root/usr.bin/rpcgen/rpc_cout.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/rpcgen/rpc_cout.c')
-rw-r--r--usr.bin/rpcgen/rpc_cout.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/usr.bin/rpcgen/rpc_cout.c b/usr.bin/rpcgen/rpc_cout.c
index 9b0915ed6a3..6430b78249f 100644
--- a/usr.bin/rpcgen/rpc_cout.c
+++ b/usr.bin/rpcgen/rpc_cout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc_cout.c,v 1.12 2002/06/01 01:40:38 deraadt Exp $ */
+/* $OpenBSD: rpc_cout.c,v 1.13 2002/07/05 05:39:42 deraadt Exp $ */
/* $NetBSD: rpc_cout.c,v 1.6 1996/10/01 04:13:53 cgd Exp $ */
/*
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
@@ -356,6 +356,10 @@ emit_union(def)
if (!streq(cs->type, "void")) {
object = alloc(strlen(def->def_name) + strlen(format) +
strlen(cs->name) + 1);
+ if (object == NULL) {
+ fprintf(stderr, "Fatal error : no memory\n");
+ crash();
+ }
if (isvectordef(cs->type, cs->rel)) {
sprintf(object, vecformat, def->def_name,
cs->name);
@@ -375,6 +379,10 @@ emit_union(def)
fprintf(fout, "\tdefault:\n");
object = alloc(strlen(def->def_name) + strlen(format) +
strlen(dflt->name) + 1);
+ if (object == NULL) {
+ fprintf(stderr, "Fatal error : no memory\n");
+ crash();
+ }
if (isvectordef(dflt->type, dflt->rel)) {
sprintf(object, vecformat, def->def_name,
dflt->name);
@@ -487,17 +495,23 @@ emit_struct(def)
dl->decl.array_max);
/* now concatenate to sizestr !!!! */
- if (sizestr == NULL)
+ if (sizestr == NULL) {
sizestr = strdup(ptemp);
- else {
- sizestr = (char *)realloc(sizestr, strlen(sizestr) + strlen(ptemp) + 1);
if (sizestr == NULL) {
- fprintf(stderr, "Fatal error : no memory\n");
+ fprintf(stderr,
+ "Fatal error : no memory\n");
crash();
}
- sizestr = strcat(sizestr, ptemp); /* build up length of
- * array */
-
+ } else {
+ sizestr = (char *)realloc(sizestr,
+ strlen(sizestr) + strlen(ptemp) + 1);
+ if (sizestr == NULL) {
+ fprintf(stderr,
+ "Fatal error : no memory\n");
+ crash();
+ }
+ /* build up length of array */
+ sizestr = strcat(sizestr, ptemp);
}
}