summaryrefslogtreecommitdiffstats
path: root/usr.bin/dc
diff options
context:
space:
mode:
authorotto <otto@openbsd.org>2008-04-28 06:35:09 +0000
committerotto <otto@openbsd.org>2008-04-28 06:35:09 +0000
commit7444001d0e25abcf60499fcff76aeaaaa2ee1f62 (patch)
tree6028fa55e4cfb3e1951195700753a13df928a3ce /usr.bin/dc
parentregen (diff)
downloadwireguard-openbsd-7444001d0e25abcf60499fcff76aeaaaa2ee1f62.tar.xz
wireguard-openbsd-7444001d0e25abcf60499fcff76aeaaaa2ee1f62.zip
plug three leaks, one reported and fixed by Andreas Gunnarsson in PR 5802,
the others by myself
Diffstat (limited to 'usr.bin/dc')
-rw-r--r--usr.bin/dc/bcode.c9
-rw-r--r--usr.bin/dc/stack.c9
2 files changed, 11 insertions, 7 deletions
diff --git a/usr.bin/dc/bcode.c b/usr.bin/dc/bcode.c
index 0549872cfaf..37e5159d898 100644
--- a/usr.bin/dc/bcode.c
+++ b/usr.bin/dc/bcode.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcode.c,v 1.36 2008/04/26 20:13:22 otto Exp $ */
+/* $OpenBSD: bcode.c,v 1.37 2008/04/28 06:35:09 otto Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
@@ -17,7 +17,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: bcode.c,v 1.36 2008/04/26 20:13:22 otto Exp $";
+static const char rcsid[] = "$OpenBSD: bcode.c,v 1.37 2008/04/28 06:35:09 otto Exp $";
#endif /* not lint */
#include <ssl/ssl.h>
@@ -822,7 +822,7 @@ load_stack(void)
{
int idx;
struct stack *stack;
- struct value *value, copy;
+ struct value *value;
idx = readreg();
if (idx >= 0) {
@@ -832,7 +832,7 @@ load_stack(void)
value = stack_pop(stack);
}
if (value != NULL)
- push(stack_dup_value(value, &copy));
+ push(value);
else
warnx("stack register '%c' (0%o) is empty",
idx, idx);
@@ -1550,6 +1550,7 @@ quitN(void)
if (n == NULL)
return;
i = get_ulong(n);
+ free_number(n);
if (i == BN_MASK2 || i == 0)
warnx("Q command requires a number >= 1");
else if (bmachine.readsp < i)
diff --git a/usr.bin/dc/stack.c b/usr.bin/dc/stack.c
index c8302574f56..a6ad404aabe 100644
--- a/usr.bin/dc/stack.c
+++ b/usr.bin/dc/stack.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stack.c,v 1.9 2006/01/16 08:09:25 otto Exp $ */
+/* $OpenBSD: stack.c,v 1.10 2008/04/28 06:35:09 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.9 2006/01/16 08:09:25 otto Exp $";
+static const char rcsid[] = "$OpenBSD: stack.c,v 1.10 2008/04/28 06:35:09 otto Exp $";
#endif /* not lint */
#include <err.h>
@@ -308,8 +308,10 @@ array_grow(struct array *array, size_t newsize)
size_t i;
array->data = brealloc(array->data, newsize * sizeof(*array->data));
- for (i = array->size; i < newsize; i++)
+ for (i = array->size; i < newsize; i++) {
+ array->data[i].type = BCODE_NONE;
array->data[i].array = NULL;
+ }
array->size = newsize;
}
@@ -318,6 +320,7 @@ array_assign(struct array *array, size_t index, const struct value *v)
{
if (index >= array->size)
array_grow(array, index+1);
+ stack_free_value(&array->data[index]);
array->data[index] = *v;
}