--- a/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c Fri Aug 29 12:00:31 2014 +0200
+++ b/jdk/src/java.base/windows/native/libjava/WinNTFileSystem_md.c Fri Aug 29 18:11:04 2014 +0400
@@ -572,10 +572,10 @@
SetLastError(error);
JNU_ThrowIOExceptionWithLastError(env, "Could not open file");
}
- }
- free(pathbuf);
- return JNI_FALSE;
}
+ free(pathbuf);
+ return JNI_FALSE;
+ }
free(pathbuf);
CloseHandle(h);
return JNI_TRUE;
@@ -636,7 +636,7 @@
if (search_path == 0) {
free (pathbuf);
errno = ENOMEM;
- JNU_ThrowOutOfMemoryError(env, "native memory allocation faiuled");
+ JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
return NULL;
}
wcscpy(search_path, pathbuf);
@@ -652,7 +652,7 @@
/* Remove trailing space chars from directory name */
len = (int)wcslen(search_path);
- while (search_path[len-1] == ' ') {
+ while (search_path[len-1] == L' ') {
len--;
}
search_path[len] = 0;
@@ -713,13 +713,15 @@
return NULL; // error
FindClose(handle);
- /* Copy the final results into an appropriately-sized array */
- old = rv;
- rv = (*env)->NewObjectArray(env, len, str_class, NULL);
- if (rv == NULL)
- return NULL; /* error */
- if (JNU_CopyObjectArray(env, rv, old, len) < 0)
- return NULL; /* error */
+ if (len < maxlen) {
+ /* Copy the final results into an appropriately-sized array */
+ old = rv;
+ rv = (*env)->NewObjectArray(env, len, str_class, NULL);
+ if (rv == NULL)
+ return NULL; /* error */
+ if (JNU_CopyObjectArray(env, rv, old, len) < 0)
+ return NULL; /* error */
+ }
return rv;
}
@@ -753,9 +755,7 @@
jboolean rv = JNI_FALSE;
WCHAR *frompath = fileToNTPath(env, from, ids.path);
WCHAR *topath = fileToNTPath(env, to, ids.path);
- if (frompath == NULL || topath == NULL)
- return JNI_FALSE;
- if (_wrename(frompath, topath) == 0) {
+ if (frompath != NULL && topath != NULL && _wrename(frompath, topath) == 0) {
rv = JNI_TRUE;
}
free(frompath);