8021943: FileDialog getFile returns corrupted string after previous setFile
authorpchelko
Wed, 04 Sep 2013 14:32:13 +0400
changeset 20111 7bfa2460d74c
parent 20110 85b98c3054f6
child 20112 a1c89924203c
8021943: FileDialog getFile returns corrupted string after previous setFile Reviewed-by: anthony, serb Contributed-by: alexander.zvegintsev@oracle.com
jdk/src/windows/native/sun/windows/awt_FileDialog.cpp
--- a/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp	Tue Sep 03 21:53:14 2013 +0400
+++ b/jdk/src/windows/native/sun/windows/awt_FileDialog.cpp	Wed Sep 04 14:32:13 2013 +0400
@@ -372,7 +372,9 @@
 
         // Report result to peer.
         if (result) {
-            jint length = (jint)GetBufferLength(ofn.lpstrFile, ofn.nMaxFile);
+            jint length = multipleMode
+                    ? (jint)GetBufferLength(ofn.lpstrFile, ofn.nMaxFile)
+                    : (jint)_tcslen(ofn.lpstrFile);
             jcharArray jnames = env->NewCharArray(length);
             env->SetCharArrayRegion(jnames, 0, length, (jchar*)ofn.lpstrFile);