#ifdef _WIN32
wchar_t *wlpath;
- utf8_to_utf16(lpath, -1, &wlpath, NULL);
+ rc = utf8_to_utf16(lpath, -1, &wlpath, NULL);
+ if (rc)
+ return rc;
env->me_lfd = CreateFileW(wlpath, GENERIC_READ|GENERIC_WRITE,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
len = OPEN_ALWAYS;
}
mode = FILE_ATTRIBUTE_NORMAL;
- utf8_to_utf16(dpath, -1, &wpath, NULL);
+ rc = utf8_to_utf16(dpath, -1, &wpath, NULL);
+ if (rc)
+ goto leave;
env->me_fd = CreateFileW(wpath, oflags, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, len, mode, NULL);
free(wpath);
*/
#ifdef _WIN32
len = OPEN_EXISTING;
- utf8_to_utf16(dpath, -1, &wpath, NULL);
+ rc = utf8_to_utf16(dpath, -1, &wpath, NULL);
+ if (rc)
+ goto leave;
env->me_mfd = CreateFileW(wpath, oflags,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, len,
mode | FILE_FLAG_WRITE_THROUGH, NULL);
* already in the OS cache.
*/
#ifdef _WIN32
- utf8_to_utf16(lpath, -1, &wpath, NULL);
+ rc = utf8_to_utf16(lpath, -1, &wpath, NULL);
+ if (rc)
+ return rc;
newfd = CreateFileW(wpath, GENERIC_WRITE, 0, NULL, CREATE_NEW,
FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH, NULL);
free(wpath);
if (need == 0)
return EINVAL;
result = malloc(sizeof(wchar_t) * need);
+ if (!result)
+ return ENOMEM;
MultiByteToWideChar(CP_UTF8, 0, src, srcsize, result, need);
if (dstsize)
*dstsize = need;