fs: clobber req->path on uv_fs_mkstemp() error
Fix issues mentioned by @vtjnash in pull request. path[0] = '\0' is more readable *(path) = '\0' and it is the standard used throghout the codebase. In windows req->path is constant string. So it's casted to char* to make it writable. Ref: https://github.com/libuv/libuv/pull/2933/
This commit is contained in:
parent
25a5d69ee6
commit
dc6fdcd7a0
@ -350,7 +350,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) {
|
|||||||
|
|
||||||
clobber:
|
clobber:
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
*(path) = '\0';
|
path[0] = '\0';
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1242,6 +1242,7 @@ void fs__mktemp(uv_fs_t* req, uv__fs_mktemp_func func) {
|
|||||||
unsigned int tries, i;
|
unsigned int tries, i;
|
||||||
size_t len;
|
size_t len;
|
||||||
uint64_t v;
|
uint64_t v;
|
||||||
|
char *path = req->path;
|
||||||
|
|
||||||
len = wcslen(req->file.pathw);
|
len = wcslen(req->file.pathw);
|
||||||
ep = req->file.pathw + len;
|
ep = req->file.pathw + len;
|
||||||
@ -1265,8 +1266,8 @@ void fs__mktemp(uv_fs_t* req, uv__fs_mktemp_func func) {
|
|||||||
|
|
||||||
if (func(req)) {
|
if (func(req)) {
|
||||||
if (req->result >= 0) {
|
if (req->result >= 0) {
|
||||||
len = strlen(req->path);
|
len = strlen(path);
|
||||||
wcstombs((char*) req->path + len - num_x, ep - num_x, num_x);
|
wcstombs(path + len - num_x, ep - num_x, num_x);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1275,7 +1276,7 @@ void fs__mktemp(uv_fs_t* req, uv__fs_mktemp_func func) {
|
|||||||
SET_REQ_RESULT(req, -1);
|
SET_REQ_RESULT(req, -1);
|
||||||
|
|
||||||
clobber:
|
clobber:
|
||||||
(char) *(req->path) = '\0';
|
path[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user