summaryrefslogtreecommitdiffstats
path: root/cmd-load-buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd-load-buffer.c')
-rw-r--r--cmd-load-buffer.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c
index c55e6c11..d81288f3 100644
--- a/cmd-load-buffer.c
+++ b/cmd-load-buffer.c
@@ -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));