diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-11-26 19:30:53 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2003-11-26 19:30:53 +0000 |
commit | 016ef3c726cf6522355c459f62ca2b73073fe6fb (patch) | |
tree | 7cbb5d7ca021b6e6f01618bc9299ed200e27c1ad /usr.bin | |
parent | 0babb8bd1ce6da391f2499fe8e589565ddba3230 (diff) |
Avoid a core dump on reading uninitiazed array locations.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/dc/stack.c | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/usr.bin/dc/stack.c b/usr.bin/dc/stack.c index 03e2f771369..4dbb2a34e25 100644 --- a/usr.bin/dc/stack.c +++ b/usr.bin/dc/stack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stack.c,v 1.5 2003/11/04 08:10:06 otto Exp $ */ +/* $OpenBSD: stack.c,v 1.6 2003/11/26 19:30:52 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> @@ -17,7 +17,7 @@ */ #ifndef lint -static const char rcsid[] = "$OpenBSD: stack.c,v 1.5 2003/11/04 08:10:06 otto Exp $"; +static const char rcsid[] = "$OpenBSD: stack.c,v 1.6 2003/11/26 19:30:52 otto Exp $"; #endif /* not lint */ #include <err.h> @@ -352,22 +352,10 @@ frame_retrieve(const struct stack *stack, size_t index) { struct array *a; + if (stack->sp == -1) + return NULL; a = stack->stack[stack->sp].array; if (a == NULL) a = stack->stack[stack->sp].array = array_new(); return array_retrieve(a, index); } - -/* -void -frame_free(struct stack *stack) -{ - struct array *a; - - a = stack->stack[stack->sp].array; - if (a != NULL) { - array_free(a); - stack->stack[stack->sp].array = NULL; - } -} -*/ |