diff --git a/src/unix/fs.c b/src/unix/fs.c index 9a8da0fa..bcb8e2c5 100644 --- a/src/unix/fs.c +++ b/src/unix/fs.c @@ -306,6 +306,7 @@ static int uv__fs_mkstemp(uv_fs_t* req) { if (path_length < pattern_size || strcmp(path + path_length - pattern_size, pattern)) { errno = EINVAL; + r = -1; goto clobber; } diff --git a/test/test-fs.c b/test/test-fs.c index ae9923a9..26a6afcf 100644 --- a/test/test-fs.c +++ b/test/test-fs.c @@ -1271,6 +1271,7 @@ TEST_IMPL(fs_mkstemp) { int r; int fd; const char path_template[] = "test_file_XXXXXX"; + const char test_file[] = "test_file"; uv_fs_t req; loop = uv_default_loop(); @@ -1290,7 +1291,10 @@ TEST_IMPL(fs_mkstemp) { ASSERT(strcmp(mkstemp_req1.path, mkstemp_req2.path) != 0); /* invalid template returns EINVAL */ - ASSERT(uv_fs_mkstemp(NULL, &mkstemp_req3, "test_file", NULL) == UV_EINVAL); + ASSERT(uv_fs_mkstemp(NULL, &mkstemp_req3, test_file, NULL) == UV_EINVAL); + + /* Make sure that path is empty string */ + ASSERT(strlen(mkstemp_req3.path) == 0); /* We can write to the opened file */ iov = uv_buf_init(test_buf, sizeof(test_buf));