summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPekka Enberg <penberg@kernel.org>2011-03-17 19:52:18 +0000
committerPekka Enberg <penberg@kernel.org>2011-03-17 19:52:18 +0000
commit92bcf9c6a0840c80fadbeda7692aa8929292c273 (patch)
treef2fba6b928a48a3ba7a3aa181e3d66d4053a9c03
parent78823a8e573b31fa78fc3e9d8e43ab429037e73e (diff)
downloadclasspath-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--ChangeLog6
-rw-r--r--native/jni/java-nio/java_nio_VMDirectByteBuffer.c7
2 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 489813aa8..533304117 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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)