summaryrefslogtreecommitdiff
path: root/usr.bin/pcc/cc
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-09-24 15:57:10 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-09-24 15:57:10 +0000
commitd72e08cc19fd8622db35472601107347aeeecd80 (patch)
tree9ddf5129e0d1a20acf248ddbe6c9b90db364147d /usr.bin/pcc/cc
parent202911337c6f74f4892f062293d5326ba79595fb (diff)
from ragge's repo:
Fix init error to give an error message instead of segfault, as reported by Otto Muerbeek.
Diffstat (limited to 'usr.bin/pcc/cc')
-rw-r--r--usr.bin/pcc/cc/ccom/init.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/pcc/cc/ccom/init.c b/usr.bin/pcc/cc/ccom/init.c
index 32938dbc2c4..ed4a6ba1a92 100644
--- a/usr.bin/pcc/cc/ccom/init.c
+++ b/usr.bin/pcc/cc/ccom/init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: init.c,v 1.4 2007/09/23 18:34:38 otto Exp $ */
+/* $OpenBSD: init.c,v 1.5 2007/09/24 15:57:09 otto Exp $ */
/*
* Copyright (c) 2004, 2007 Anders Magnusson (ragge@ludd.ltu.se).
@@ -282,10 +282,14 @@ stkpush(void)
is->in_df = sp->sdf;
} else if (ISSOU(t)) {
sq = *pstk->in_xp;
- is->in_xp = ISSOU(sq->stype) ? sq->ssue->suelem : 0;
- is->in_t = sq->stype;
- is->in_sym = sq;
- is->in_df = sq->sdf;
+ if (sq == NULL) {
+ uerror("excess of initializing elements");
+ } else {
+ is->in_xp = ISSOU(sq->stype) ? sq->ssue->suelem : 0;
+ is->in_t = sq->stype;
+ is->in_sym = sq;
+ is->in_df = sq->sdf;
+ }
} else if (ISARY(t)) {
is->in_xp = ISSOU(DECREF(t)) ? pstk->in_sym->ssue->suelem : 0;
is->in_t = DECREF(t);