summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2014-11-26 15:05:51 +0000
committerotto <otto@openbsd.org>2014-11-26 15:05:51 +0000
commit311bfd08d113ba9da7edc78d89f96a7ea461b467 (patch)
treef47d6913ebc96d36d02f43345a152df34342fd65
parentsync (diff)
downloadwireguard-openbsd-311bfd08d113ba9da7edc78d89f96a7ea461b467.tar.xz
wireguard-openbsd-311bfd08d113ba9da7edc78d89f96a7ea461b467.zip
init array field in the proper place, see regress test t27;
from Sebastien Marie
-rw-r--r--usr.bin/dc/stack.c8
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