# HG changeset patch # User jzavgren # Date 1361290749 0 # Node ID 2734ca906c3e80cd0141ee1c8645f7c3552cd97c # Parent cf20f016fa9432f0e62a6af2f6c44994de9597c3 8007609: WinNTFileSystem_md.c should correctly check value returned from realloc Reviewed-by: alanb, chegar, dholmes diff -r cf20f016fa94 -r 2734ca906c3e jdk/src/windows/native/java/io/WinNTFileSystem_md.c --- a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c Tue Feb 19 14:12:09 2013 +0000 +++ b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c Tue Feb 19 16:19:09 2013 +0000 @@ -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 @@ 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)