summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/cmd-load-buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/tmux/cmd-load-buffer.c')
-rw-r--r--usr.bin/tmux/cmd-load-buffer.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/usr.bin/tmux/cmd-load-buffer.c b/usr.bin/tmux/cmd-load-buffer.c
index 39637013bfe..f60398669f3 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.35 2015/10/31 08:13:58 nicm Exp $ */
+/* $OpenBSD: cmd-load-buffer.c,v 1.36 2015/11/10 22:29:33 nicm Exp $ */
/*
* Copyright (c) 2009 Tiago Cunha <me@tiagocunha.org>
@@ -77,11 +77,15 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
else
cwd = ".";
- xasprintf(&file, "%s/%s", cwd, path);
- if (realpath(file, resolved) == NULL)
- f = NULL;
+ if (*path == '/')
+ file = xstrdup(path);
else
- f = fopen(resolved, "rb");
+ xasprintf(&file, "%s/%s", cwd, path);
+ if (realpath(file, resolved) == NULL) {
+ cmdq_error(cmdq, "%s: %s", file, strerror(errno));
+ return (CMD_RETURN_ERROR);
+ }
+ f = fopen(resolved, "rb");
free(file);
if (f == NULL) {
cmdq_error(cmdq, "%s: %s", resolved, strerror(errno));