summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-01-09 19:32:35 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-01-09 19:32:35 +0000
commit9335e2a5bb0188cd7c1ab3bc5a70cc4362db29a1 (patch)
tree07c7a0a131f85a0f65b692a4c3cfc56054759de0 /usr.bin
parentfc41283a6f31889cd1286864915434c8f6abf902 (diff)
behave reasonably if malloc fails
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/sup/src/stree.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/usr.bin/sup/src/stree.c b/usr.bin/sup/src/stree.c
index e27f6432227..89a8d570394 100644
--- a/usr.bin/sup/src/stree.c
+++ b/usr.bin/sup/src/stree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stree.c,v 1.5 1997/09/16 11:01:18 deraadt Exp $ */
+/* $OpenBSD: stree.c,v 1.6 1999/01/09 19:32:34 millert Exp $ */
/*
* Copyright (c) 1992 Carnegie Mellon University
@@ -87,20 +87,22 @@ char *p;
{
register TREE *t;
t = (TREE *) malloc (sizeof (TREE));
- t->Tname = (p == NULL) ? NULL : salloc (p);
- t->Tflags = 0;
- t->Tuid = 0;
- t->Tgid = 0;
- t->Tuser = NULL;
- t->Tgroup = NULL;
- t->Tmode = 0;
- t->Tctime = 0;
- t->Tmtime = 0;
- t->Tlink = NULL;
- t->Texec = NULL;
- t->Tbf = 0;
- t->Tlo = NULL;
- t->Thi = NULL;
+ if (t != NULL) {
+ t->Tname = (p == NULL) ? NULL : salloc (p);
+ t->Tflags = 0;
+ t->Tuid = 0;
+ t->Tgid = 0;
+ t->Tuser = NULL;
+ t->Tgroup = NULL;
+ t->Tmode = 0;
+ t->Tctime = 0;
+ t->Tmtime = 0;
+ t->Tlink = NULL;
+ t->Texec = NULL;
+ t->Tbf = 0;
+ t->Tlo = NULL;
+ t->Thi = NULL;
+ }
return (t);
}
@@ -195,8 +197,8 @@ int *dh;
int deltah;
if (*t == NULL) {
- *t = Tmake (p);
- *dh = 1;
+ if ((*t = Tmake (p)) != NULL)
+ *dh = 1;
return (*t);
}
if ((cmp = strcmp(p, (*t)->Tname)) == 0) {