diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-02-17 23:07:04 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2014-02-17 23:07:04 +0000 |
commit | 02df93feb6ccbddc394a87b2889167881fdb3708 (patch) | |
tree | 239af5879f088728fb30bfd2012128b174d0ec41 /usr.bin | |
parent | cf90bbdad150cd1224f1d483f9057fff5e0b35ec (diff) |
Fix memory leaks with paste_replace, based on changes from J Raynor.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/cmd-load-buffer.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/paste.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 6 |
3 files changed, 9 insertions, 6 deletions
diff --git a/usr.bin/tmux/cmd-load-buffer.c b/usr.bin/tmux/cmd-load-buffer.c index 121bd665494..e98e54a8f42 100644 --- a/usr.bin/tmux/cmd-load-buffer.c +++ b/usr.bin/tmux/cmd-load-buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-load-buffer.c,v 1.26 2014/02/14 13:59:01 nicm Exp $ */ +/* $OpenBSD: cmd-load-buffer.c,v 1.27 2014/02/17 23:07:03 nicm Exp $ */ /* * Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org> @@ -169,6 +169,7 @@ cmd_load_buffer_callback(struct client *c, int closed, void *data) /* No context so can't use server_client_msg_error. */ evbuffer_add_printf(c->stderr_data, "no buffer %d\n", *buffer); server_push_stderr(c); + free(pdata); } free(data); diff --git a/usr.bin/tmux/paste.c b/usr.bin/tmux/paste.c index b79d41c76d0..b6f0f16939d 100644 --- a/usr.bin/tmux/paste.c +++ b/usr.bin/tmux/paste.c @@ -1,4 +1,4 @@ -/* $OpenBSD: paste.c,v 1.14 2012/11/27 20:22:12 nicm Exp $ */ +/* $OpenBSD: paste.c,v 1.15 2014/02/17 23:07:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -131,8 +131,10 @@ paste_replace(struct paste_stack *ps, u_int idx, char *data, size_t size) { struct paste_buffer *pb; - if (size == 0) + if (size == 0) { + free(data); return (0); + } if (idx >= ARRAY_LENGTH(ps)) return (-1); diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 34d9b28c41c..c8f936025bd 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.101 2014/01/28 23:07:09 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.102 2014/02/17 23:07:03 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1455,8 +1455,8 @@ window_copy_copy_buffer(struct window_pane *wp, int idx, void *buf, size_t len) if (idx == -1) { limit = options_get_number(&global_options, "buffer-limit"); paste_add(&global_buffers, buf, len, limit); - } else - paste_replace(&global_buffers, idx, buf, len); + } else if (paste_replace(&global_buffers, idx, buf, len) != 0) + free(buf); } void |