diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-30 20:50:55 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-30 20:50:55 +0000 |
commit | a620dde9711811952804f941e8a2cb025c5838f6 (patch) | |
tree | 6b316e5e390c1509f32eded227f1b1adb8934fd4 | |
parent | 344c6cad5042ee9488e7fe232035880bf95ab952 (diff) |
Don't leak when rollling buffers off when the paste buffer limit is reached.
-rw-r--r-- | usr.bin/tmux/paste.c | 8 |
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); |