diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2008-04-28 06:35:10 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2008-04-28 06:35:10 +0000 |
commit | 9b684a999cc2c371a445843d766ddfd0419627ce (patch) | |
tree | 967712d995c751b144d3ad3543d44cb0c6354377 /usr.bin | |
parent | 416b7ad491485d877443a1aa10f7b8685748af34 (diff) |
plug three leaks, one reported and fixed by Andreas Gunnarsson in PR 5802,
the others by myself
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/dc/bcode.c | 9 | ||||
-rw-r--r-- | usr.bin/dc/stack.c | 9 |
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, ©)); + 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; } |