提交 22dbcf85 编写于 作者: J jzavgren

8007609: WinNTFileSystem_md.c should correctly check value returned from realloc

Reviewed-by: alanb, chegar, dholmes
上级 2e3f6411
......@@ -36,9 +36,7 @@
#include <windows.h>
#include <io.h>
#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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册