8133034: launcher crashes if started with non english arguments JDK-8200758-branch
authorherrick
Mon, 08 Oct 2018 18:10:31 -0400
branchJDK-8200758-branch
changeset 56940 93d2d065257e
parent 56935 344eb87a55fb
child 56941 20568f1e1aa7
8133034: launcher crashes if started with non english arguments Submitten-by: almatvee Reviewed-by: herrick
src/jdk.packager/share/native/library/common/PlatformString.cpp
--- a/src/jdk.packager/share/native/library/common/PlatformString.cpp	Fri Oct 05 14:47:35 2018 -0400
+++ b/src/jdk.packager/share/native/library/common/PlatformString.cpp	Mon Oct 08 18:10:31 2018 -0400
@@ -133,14 +133,18 @@
     MultibyteString result;
     size_t count = 0;
 
+    if (value == NULL) {
+        return result;
+    }
+
 #ifdef WINDOWS
-    wcstombs_s(&count, NULL, 0, value, 0);
+    count = WideCharToMultiByte(CP_UTF8, 0, value, -1, NULL, 0, NULL, NULL);
 
     if (count > 0) {
         result.data = new char[count + 1];
-        wcstombs_s(&result.length, result.data, count, value, count);
+        result.length = WideCharToMultiByte(CP_UTF8, 0, value, -1, result.data, (int)count, NULL, NULL);
+#endif //WINDOWS
 
-#endif //WINDOWS
 #ifdef POSIX
     count = wcstombs(NULL, value, 0);
 
@@ -160,6 +164,10 @@
     WideString result;
     size_t count = 0;
 
+    if (value == NULL) {
+        return result;
+    }
+
 #ifdef WINDOWS
     mbstowcs_s(&count, NULL, 0, value, _TRUNCATE);