diff options
author | Pekka Enberg <penberg@kernel.org> | 2011-03-17 19:52:18 +0000 |
---|---|---|
committer | Pekka Enberg <penberg@kernel.org> | 2011-03-17 19:52:18 +0000 |
commit | 92bcf9c6a0840c80fadbeda7692aa8929292c273 (patch) | |
tree | f2fba6b928a48a3ba7a3aa181e3d66d4053a9c03 | |
parent | 78823a8e573b31fa78fc3e9d8e43ab429037e73e (diff) | |
download | classpath-92bcf9c6a0840c80fadbeda7692aa8929292c273.tar.gz |
Fix Java_java_nio_VMDirectByteBuffer_allocate() for negative capacity
JavaDocs clearly state that ByteBuffer.allocateDirect() must throw
IllegalArgumentException if capacity is negative.
2011-03-17 Pekka Enberg <penberg@kernel.org>
* native/jni/java-nio/java_nio_VMDirectByteBuffer.c:
(Java_java_nio_VMDirectByteBuffer_allocate): Check for negative
capacity.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | native/jni/java-nio/java_nio_VMDirectByteBuffer.c | 7 |
2 files changed, 13 insertions, 0 deletions
@@ -1,3 +1,9 @@ +2011-03-17 Pekka Enberg <penberg@kernel.org> + + * native/jni/java-nio/java_nio_VMDirectByteBuffer.c: + (Java_java_nio_VMDirectByteBuffer_allocate): Check for negative + capacity. + 2011-03-14 Andrew John Hughes <ahughes@redhat.com> PR classpath/42390 diff --git a/native/jni/java-nio/java_nio_VMDirectByteBuffer.c b/native/jni/java-nio/java_nio_VMDirectByteBuffer.c index bfee7e9dc..7325c5b8b 100644 --- a/native/jni/java-nio/java_nio_VMDirectByteBuffer.c +++ b/native/jni/java-nio/java_nio_VMDirectByteBuffer.c @@ -51,6 +51,13 @@ Java_java_nio_VMDirectByteBuffer_allocate { void *buffer; + if (capacity < 0) + { + JCL_ThrowException (env, "java/lang/IllegalArgumentException", + "negative capacity"); + return 0; + } + buffer = malloc (capacity); if (buffer == NULL) |