diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-10-26 21:25:57 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-10-26 21:25:57 +0000 |
commit | 6b804f3a4aaffc26d419b3ad7f96bd54456cdfc5 (patch) | |
tree | b3c5f98a0feb8ec58d8bcb89a2f65d5150d08bb2 /cmd-load-buffer.c | |
parent | 539c73bdb1865ad57600e3759f2475adef79ab41 (diff) | |
download | rtmux-6b804f3a4aaffc26d419b3ad7f96bd54456cdfc5.tar.gz rtmux-6b804f3a4aaffc26d419b3ad7f96bd54456cdfc5.tar.bz2 rtmux-6b804f3a4aaffc26d419b3ad7f96bd54456cdfc5.zip |
Call fstat() after fopen() rather than stat() before.
Diffstat (limited to 'cmd-load-buffer.c')
-rw-r--r-- | cmd-load-buffer.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd-load-buffer.c b/cmd-load-buffer.c index 1f8e75cd..a3f09ca4 100644 --- a/cmd-load-buffer.c +++ b/cmd-load-buffer.c @@ -56,13 +56,14 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx) if ((s = cmd_find_session(ctx, data->target)) == NULL) return (-1); - if (stat(data->arg, &sb) < 0) { + if ((f = fopen(data->arg, "rb")) == NULL) { ctx->error(ctx, "%s: %s", data->arg, strerror(errno)); return (-1); } - if ((f = fopen(data->arg, "rb")) == NULL) { + if (fstat(fileno(f), &sb) < 0) { ctx->error(ctx, "%s: %s", data->arg, strerror(errno)); + fclose(f); return (-1); } |