提交 863596d8 编写于 作者: I igerasim

8207060: Memory leak when malloc fails within WITH_UNICODE_STRING block

Reviewed-by: vtewari, rriggs
上级 755ffd51
/* /*
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -169,9 +169,6 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) { ...@@ -169,9 +169,6 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) {
pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR)); pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
if (pathbuf != 0) { if (pathbuf != 0) {
wcscpy(pathbuf, ps); wcscpy(pathbuf, ps);
} else {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
return NULL;
} }
} }
} else { } else {
...@@ -199,9 +196,6 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) { ...@@ -199,9 +196,6 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) {
pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR)); pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
if (pathbuf != 0) { if (pathbuf != 0) {
wcscpy(pathbuf, ps); wcscpy(pathbuf, ps);
} else {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
return NULL;
} }
} }
} }
...@@ -218,9 +212,6 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) { ...@@ -218,9 +212,6 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) {
pathbuf = (WCHAR*)malloc(sizeof(WCHAR)); pathbuf = (WCHAR*)malloc(sizeof(WCHAR));
if (pathbuf != NULL) { if (pathbuf != NULL) {
pathbuf[0] = L'\0'; pathbuf[0] = L'\0';
} else {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
return NULL;
} }
} }
} }
...@@ -228,7 +219,6 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) { ...@@ -228,7 +219,6 @@ pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE) {
if (!(*env)->ExceptionCheck(env)) { if (!(*env)->ExceptionCheck(env)) {
JNU_ThrowOutOfMemoryError(env, "native memory allocation failed"); JNU_ThrowOutOfMemoryError(env, "native memory allocation failed");
} }
return NULL;
} }
return pathbuf; return pathbuf;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册