< prev index next >

src/java.base/windows/native/libjava/canonicalize_md.c

Print this page

        

*** 328,346 **** Converts to wchar and delegates to wcanonicalize. */ JNIEXPORT int JDK_Canonicalize(const char *orig, char *out, int len) { wchar_t* wpath = NULL; wchar_t* wresult = NULL; ! size_t conv; ! size_t path_len = strlen(orig); int ret = -1; ! if ((wpath = (wchar_t*) malloc(sizeof(wchar_t) * (path_len + 1))) == NULL) { goto finish; } ! if (mbstowcs_s(&conv, wpath, path_len + 1, orig, path_len) != 0) { goto finish; } if ((wresult = (wchar_t*) malloc(sizeof(wchar_t) * len)) == NULL) { goto finish; --- 328,353 ---- Converts to wchar and delegates to wcanonicalize. */ JNIEXPORT int JDK_Canonicalize(const char *orig, char *out, int len) { wchar_t* wpath = NULL; wchar_t* wresult = NULL; ! int wpath_len; int ret = -1; ! /* Get required buffer size to convert to Unicode */ ! wpath_len = MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS, ! orig, -1, NULL, 0); ! if (wpath_len == 0) { goto finish; } ! if ((wpath = (wchar_t*) malloc(sizeof(wchar_t) * wpath_len)) == NULL) { ! goto finish; ! } ! ! if (MultiByteToWideChar(CP_THREAD_ACP, MB_ERR_INVALID_CHARS, ! orig, -1, wpath, wpath_len) == 0) { goto finish; } if ((wresult = (wchar_t*) malloc(sizeof(wchar_t) * len)) == NULL) { goto finish;
*** 348,358 **** if (wcanonicalize(wpath, wresult, len) != 0) { goto finish; } ! if (wcstombs_s(&conv, out, (size_t) len, wresult, (size_t) (len - 1)) != 0) { goto finish; } // Change return value to success. ret = 0; --- 355,366 ---- if (wcanonicalize(wpath, wresult, len) != 0) { goto finish; } ! if (WideCharToMultiByte(CP_THREAD_ACP, 0, ! wresult, -1, out, len, NULL, NULL) == 0) { goto finish; } // Change return value to success. ret = 0;
< prev index next >