summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/paste.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2009-07-30 20:50:54 +0000
committernicm <nicm@openbsd.org>2009-07-30 20:50:54 +0000
commit6e06e05fbc0a34c963b5afba879d5f5e7160f1c4 (patch)
tree02534c4e28e78c875dbf121c93e907702ce5b79c /usr.bin/tmux/paste.c
parentPlug some memory leaks. (diff)
downloadwireguard-openbsd-6e06e05fbc0a34c963b5afba879d5f5e7160f1c4.tar.xz
wireguard-openbsd-6e06e05fbc0a34c963b5afba879d5f5e7160f1c4.zip
Don't leak when rollling buffers off when the paste buffer limit is reached.
Diffstat (limited to 'usr.bin/tmux/paste.c')
-rw-r--r--usr.bin/tmux/paste.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/tmux/paste.c b/usr.bin/tmux/paste.c
index a76b47eea52..c9ef68ac81f 100644
--- a/usr.bin/tmux/paste.c
+++ b/usr.bin/tmux/paste.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: paste.c,v 1.2 2009/07/02 16:15:43 nicm Exp $ */
+/* $OpenBSD: paste.c,v 1.3 2009/07/30 20:50:54 nicm 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);