summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2018-07-31 13:06:45 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2018-07-31 13:06:45 +0000
commit24f0d15aee4242bde5d4e6c2f919728f1910cb5b (patch)
tree8b7e81c1df71fba8c9e1c4394d4a30e661a87d4a /usr.bin
parentdf1f5ef9b02992c9a32574dd6d13c09c982ef3b8 (diff)
Do not leak path or use it after free.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/cmd-load-buffer.c6
-rw-r--r--usr.bin/tmux/cmd-save-buffer.c5
2 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/tmux/cmd-load-buffer.c b/usr.bin/tmux/cmd-load-buffer.c
index f89d4691d46..5309dc8925d 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.52 2018/07/11 08:29:21 nicm Exp $ */
+/* $OpenBSD: cmd-load-buffer.c,v 1.53 2018/07/31 13:06:44 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -85,7 +85,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
error = server_set_stdin_callback(c, cmd_load_buffer_callback,
cdata, &cause);
if (error != 0) {
- cmdq_error(item, "%s: %s", path, cause);
+ cmdq_error(item, "-: %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
@@ -93,6 +93,8 @@ cmd_load_buffer_exec(struct cmd *self, struct cmdq_item *item)
}
file = server_client_get_path(c, path);
+ free(path);
+
f = fopen(file, "rb");
if (f == NULL) {
cmdq_error(item, "%s: %s", file, strerror(errno));
diff --git a/usr.bin/tmux/cmd-save-buffer.c b/usr.bin/tmux/cmd-save-buffer.c
index 1f433c72eed..20b05650caa 100644
--- a/usr.bin/tmux/cmd-save-buffer.c
+++ b/usr.bin/tmux/cmd-save-buffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-save-buffer.c,v 1.44 2018/07/11 08:29:21 nicm Exp $ */
+/* $OpenBSD: cmd-save-buffer.c,v 1.45 2018/07/31 13:06:44 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -106,6 +106,8 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
flags = "ab";
file = server_client_get_path(c, path);
+ free(path);
+
f = fopen(file, flags);
if (f == NULL) {
cmdq_error(item, "%s: %s", file, strerror(errno));
@@ -122,7 +124,6 @@ cmd_save_buffer_exec(struct cmd *self, struct cmdq_item *item)
fclose(f);
free(file);
- free(path);
return (CMD_RETURN_NORMAL);