diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2014-11-26 15:05:52 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2014-11-26 15:05:52 +0000 |
commit | a65d241acb3a291dc4bc74f076a62fa2c35208b0 (patch) | |
tree | e1fcfe2a3a81f26f03ee0a86db0bec6afc6ffea5 | |
parent | cd33d89571ef162019b6488b1c8d24286c227194 (diff) |
init array field in the proper place, see regress test t27;
from Sebastien Marie
-rw-r--r-- | usr.bin/dc/stack.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.bin/dc/stack.c b/usr.bin/dc/stack.c index 0ed3164ae13..41309681324 100644 --- a/usr.bin/dc/stack.c +++ b/usr.bin/dc/stack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stack.c,v 1.11 2009/10/27 23:59:37 deraadt Exp $ */ +/* $OpenBSD: stack.c,v 1.12 2014/11/26 15:05:51 otto Exp $ */ /* * Copyright (c) 2003, Otto Moerbeek <otto@drijf.net> @@ -129,14 +129,12 @@ stack_swap(struct stack *stack) static void stack_grow(struct stack *stack) { - size_t new_size, i; + size_t new_size; if (++stack->sp == stack->size) { new_size = stack->size * 2 + 1; stack->stack = brealloc(stack->stack, new_size * sizeof(*stack->stack)); - for (i = stack->size; i < new_size; i++) - stack->stack[i].array = NULL; stack->size = new_size; } } @@ -147,6 +145,7 @@ stack_pushnumber(struct stack *stack, struct number *b) stack_grow(stack); stack->stack[stack->sp].type = BCODE_NUMBER; stack->stack[stack->sp].u.num = b; + stack->stack[stack->sp].array = NULL; } void @@ -155,6 +154,7 @@ stack_pushstring(struct stack *stack, char *string) stack_grow(stack); stack->stack[stack->sp].type = BCODE_STRING; stack->stack[stack->sp].u.string = string; + stack->stack[stack->sp].array = NULL; } void |