src/windows/native/sun/windows/awt_FileDialog.cpp

Print this page

        

@@ -370,11 +370,13 @@
 
         VERIFY(::SetCurrentDirectory(currentDirectory));
 
         // 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);
 
             env->CallVoidMethod(peer, AwtFileDialog::handleSelectedMID, jnames);
             env->DeleteLocalRef(jnames);