summaryrefslogtreecommitdiffstats
path: root/paste.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-07-31 20:33:49 +0000
committerTiago Cunha <tcunha@gmx.com>2009-07-31 20:33:49 +0000
commitcccd072ed17a34c928411c231f6863a7aa769ce4 (patch)
treeff7ddafcc021a03d946e534250e2356d34bb9bf4 /paste.c
parent5f0e688b50dedb7802852da00408e8e80fa8a4be (diff)
Sync OpenBSD patchset 208:
Don't leak when rollling buffers off when the paste buffer limit is reached.
Diffstat (limited to 'paste.c')
-rw-r--r--paste.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/paste.c b/paste.c
index 36c40060..80367ff2 100644
--- a/paste.c
+++ b/paste.c
@@ -1,4 +1,4 @@
-/* $Id: paste.c,v 1.7 2009-07-02 16:23:54 nicm Exp $ */
+/* $Id: paste.c,v 1.8 2009-07-31 20:33:49 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -104,8 +104,12 @@ paste_add(struct paste_stack *ps, char *data, u_int limit)
if (*data == '\0')
return;
- while (ARRAY_LENGTH(ps) >= limit)
+ while (ARRAY_LENGTH(ps) >= limit) {
+ pb = ARRAY_LAST(ps);
+ xfree(pb->data);
+ xfree(pb);
ARRAY_TRUNC(ps, 1);
+ }
pb = xmalloc(sizeof *pb);
ARRAY_INSERT(ps, 0, pb);