This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: fix java.nio.DirectByteBufferImpl memory ownership bug


I tracked this one down thanks to jogl.  

If DirectByteBufferImpl is created with a raw buffer pointer, via JNI
say, then we need to set "owner" to null.  If we don't do this, then our
finalizer will try to free() this memory resulting in badness.  This is
explained in the comments at the top of the source file.

Ok for HEAD and 4.0 branch?

AG


2005-04-02  Anthony Green  <green@redhat.com>

	* java/nio/DirectByteBufferImpl.java: Fix buffer ownership bug.


Index: java/nio/DirectByteBufferImpl.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/nio/DirectByteBufferImpl.java,v
retrieving revision 1.20
diff -u -p -r1.20 DirectByteBufferImpl.java
--- java/nio/DirectByteBufferImpl.java	22 Feb 2005 13:02:07 -0000	1.20
+++ java/nio/DirectByteBufferImpl.java	3 Apr 2005 06:39:57 -0000
@@ -117,7 +117,7 @@ abstract class DirectByteBufferImpl exte
   DirectByteBufferImpl(RawData address, int capacity)
   {
     super(capacity, capacity, 0, -1);
-    this.owner = this;
+    this.owner = null;
     this.address = address;
   }
   



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]