diff --git a/src/windows/native/java/io/WinNTFileSystem_md.c b/src/windows/native/java/io/WinNTFileSystem_md.c index f1eb449275ee7b2d31e35dc3da411f219ac1f6e4..60cc71e0aebd6e61032a13b2b24190d7893a51f3 100644 --- a/src/windows/native/java/io/WinNTFileSystem_md.c +++ b/src/windows/native/java/io/WinNTFileSystem_md.c @@ -36,9 +36,7 @@ #include #include -#include "jvm.h" #include "jni.h" -#include "jni_util.h" #include "io_util.h" #include "jlong.h" #include "io_util_md.h" @@ -115,13 +113,15 @@ static WCHAR* getFinalPath(const WCHAR *path) DWORD len = (*GetFinalPathNameByHandle_func)(h, result, MAX_PATH, 0); if (len >= MAX_PATH) { /* retry with a buffer of the right size */ - result = (WCHAR*)realloc(result, (len+1) * sizeof(WCHAR)); - if (result != NULL) { + WCHAR* newResult = (WCHAR*)realloc(result, (len+1) * sizeof(WCHAR)); + if (newResult != NULL) { + result = newResult; len = (*GetFinalPathNameByHandle_func)(h, result, len, 0); } else { len = 0; } } + if (len > 0) { /** * Strip prefix (should be \\?\ or \\?\UNC)