diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-08-10 03:59:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-10 03:59:43 +0200 |
commit | de1084f3c48816e96be3cac28bcf56bd321ad800 (patch) | |
tree | 79fde721bd1c0ae176670faae2122957e10280b0 /src | |
parent | 085102fadf1c1371e863c0e9af8240038ce641e2 (diff) | |
parent | 7ae744b93d80fd169507732931606276844150b6 (diff) | |
download | rneovim-de1084f3c48816e96be3cac28bcf56bd321ad800.tar.gz rneovim-de1084f3c48816e96be3cac28bcf56bd321ad800.tar.bz2 rneovim-de1084f3c48816e96be3cac28bcf56bd321ad800.zip |
Merge #7140 'os_stat: return ENOENT on NULL fname'
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/fileio.c | 11 | ||||
-rw-r--r-- | src/nvim/os/fs.c | 9 |
2 files changed, 9 insertions, 11 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 643020df5e..feb16f44d4 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -2570,11 +2570,9 @@ buf_write ( perm = -1; } } -#else /* win32 */ - /* - * Check for a writable device name. - */ - c = os_nodetype((char *)fname); +#else // win32 + // Check for a writable device name. + c = fname == NULL ? NODE_OTHER : os_nodetype((char *)fname); if (c == NODE_OTHER) { SET_ERRMSG_NUM("E503", _("is not a file or writable device")); goto fail; @@ -2594,9 +2592,8 @@ buf_write ( if (overwriting) { os_fileinfo((char *)fname, &file_info_old); } - } -#endif /* !UNIX */ +#endif // !UNIX if (!device && !newfile) { /* diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 9e3025cf89..6ac9d682d7 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -605,8 +605,11 @@ int os_fsync(int fd) /// /// @return libuv return code. static int os_stat(const char *name, uv_stat_t *statbuf) - FUNC_ATTR_NONNULL_ALL + FUNC_ATTR_NONNULL_ARG(2) { + if (!name) { + return UV_ENOENT; + } uv_fs_t request; int result = uv_fs_stat(&fs_loop, &request, name, NULL); *statbuf = request.statbuf; @@ -618,7 +621,6 @@ static int os_stat(const char *name, uv_stat_t *statbuf) /// /// @return libuv error code on error. int32_t os_getperm(const char *name) - FUNC_ATTR_NONNULL_ALL { uv_stat_t statbuf; int stat_result = os_stat(name, &statbuf); @@ -657,7 +659,6 @@ int os_fchown(int fd, uv_uid_t owner, uv_gid_t group) /// /// @return `true` if `path` exists bool os_path_exists(const char_u *path) - FUNC_ATTR_NONNULL_ALL { uv_stat_t statbuf; return os_stat((char *)path, &statbuf) == kLibuvSuccess; @@ -847,7 +848,7 @@ int os_remove(const char *path) /// @param[out] file_info Pointer to a FileInfo to put the information in. /// @return `true` on success, `false` for failure. bool os_fileinfo(const char *path, FileInfo *file_info) - FUNC_ATTR_NONNULL_ALL + FUNC_ATTR_NONNULL_ARG(2) { return os_stat(path, &(file_info->stat)) == kLibuvSuccess; } |