8282397: createTempFile method of java.io.File is failing when called with suffix of spaces character

Reviewed-by: bae
Backport-of: d48181536fa9b99f01fc80f8adb73777ec6ffa58
This commit is contained in:
Yuri Nesterenko 2022-03-24 16:57:12 +03:00 committed by Andrew Brygin
parent 780ea14119
commit a4c19d9e66

View File

@ -359,9 +359,12 @@ class Win32FileSystem extends FileSystem {
// is a ":" at position 1 and the first character is not a letter
String pathname = f.getPath();
int lastColon = pathname.lastIndexOf(":");
if (lastColon > 1 ||
(lastColon == 1 && !isLetter(pathname.charAt(0))))
return true;
// Valid if there is no ":" present or if the last ":" present is
// at index 1 and the first character is a latter
if (lastColon < 0 ||
(lastColon == 1 && isLetter(pathname.charAt(0))))
return false;
// Invalid if path creation fails
Path path = null;