From aab669a05f943c587f6acccd94d53a8544170c1c Mon Sep 17 00:00:00 2001 From: Konstantin Tokarev Date: Thu, 15 Jun 2017 12:13:20 +0300 Subject: Import WebKit commit 6d0ad27b6bc4209fb8d8cee2692dc0c6a5462051 Change-Id: Ifdedb7bc3162434686201813dc1d994cf5ae7e70 Reviewed-by: Konstantin Tokarev --- Source/JavaScriptCore/jsc.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Source/JavaScriptCore/jsc.cpp') diff --git a/Source/JavaScriptCore/jsc.cpp b/Source/JavaScriptCore/jsc.cpp index d9f888fb1..c0a84fc5f 100644 --- a/Source/JavaScriptCore/jsc.cpp +++ b/Source/JavaScriptCore/jsc.cpp @@ -68,6 +68,7 @@ #if OS(WINDOWS) #include +#include #else #include #endif @@ -868,8 +869,7 @@ static bool currentWorkingDirectory(DirectoryName& directoryName) // https://msdn.microsoft.com/en-us/library/windows/desktop/ff381407.aspx auto buffer = std::make_unique(bufferLength); DWORD lengthNotIncludingNull = ::GetCurrentDirectoryW(bufferLength, buffer.get()); - static_assert(sizeof(wchar_t) == sizeof(UChar), "In Windows, both are UTF-16LE"); - String directoryString = String(reinterpret_cast(buffer.get())); + String directoryString = wcharToString(buffer.get(), lengthNotIncludingNull); // We don't support network path like \\host\share\. if (directoryString.startsWith("\\\\")) return false; @@ -999,9 +999,7 @@ static bool fetchModuleFromLocalFileSystem(const String& fileName, Vector& // https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247.aspx#maxpath // Use long UNC to pass the long path name to the Windows APIs. String longUNCPathName = WTF::makeString("\\\\?\\", fileName); - static_assert(sizeof(wchar_t) == sizeof(UChar), "In Windows, both are UTF-16LE"); - auto utf16Vector = longUNCPathName.charactersWithNullTermination(); - FILE* f = _wfopen(reinterpret_cast(utf16Vector.data()), L"rb"); + FILE* f = _wfopen(stringToNullTerminatedWChar(longUNCPathName).data(), L"rb"); #else FILE* f = fopen(fileName.utf8().data(), "r"); #endif -- cgit v1.2.1