提交 0702fbef 编写于 作者: M martin

6632696: Writing to closed output files (writeBytes) leaks native memory (unix)

Reviewed-by: alanb, iris
上级 2a6ea3fd
...@@ -40,7 +40,7 @@ readSingle(JNIEnv *env, jobject this, jfieldID fid) { ...@@ -40,7 +40,7 @@ readSingle(JNIEnv *env, jobject this, jfieldID fid) {
char ret; char ret;
FD fd = GET_FD(this, fid); FD fd = GET_FD(this, fid);
if (fd == -1) { if (fd == -1) {
JNU_ThrowIOException (env, "Stream Closed"); JNU_ThrowIOException(env, "Stream Closed");
return -1; return -1;
} }
nread = IO_Read(fd, &ret, 1); nread = IO_Read(fd, &ret, 1);
...@@ -94,7 +94,7 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes, ...@@ -94,7 +94,7 @@ readBytes(JNIEnv *env, jobject this, jbyteArray bytes,
fd = GET_FD(this, fid); fd = GET_FD(this, fid);
if (fd == -1) { if (fd == -1) {
JNU_ThrowIOException (env, "Stream Closed"); JNU_ThrowIOException(env, "Stream Closed");
return -1; return -1;
} }
...@@ -121,7 +121,7 @@ writeSingle(JNIEnv *env, jobject this, jint byte, jfieldID fid) { ...@@ -121,7 +121,7 @@ writeSingle(JNIEnv *env, jobject this, jint byte, jfieldID fid) {
int n; int n;
FD fd = GET_FD(this, fid); FD fd = GET_FD(this, fid);
if (fd == -1) { if (fd == -1) {
JNU_ThrowIOException (env, "Stream Closed"); JNU_ThrowIOException(env, "Stream Closed");
return; return;
} }
n = IO_Write(fd, &c, 1); n = IO_Write(fd, &c, 1);
...@@ -172,8 +172,8 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes, ...@@ -172,8 +172,8 @@ writeBytes(JNIEnv *env, jobject this, jbyteArray bytes,
while (len > 0) { while (len > 0) {
fd = GET_FD(this, fid); fd = GET_FD(this, fid);
if (fd == -1) { if (fd == -1) {
JNU_ThrowIOException (env, "Stream Closed"); JNU_ThrowIOException(env, "Stream Closed");
return; break;
} }
n = IO_Write(fd, buf+off, len); n = IO_Write(fd, buf+off, len);
if (n == JVM_IO_ERR) { if (n == JVM_IO_ERR) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册