You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/04/27 09:12:23 UTC
svn commit: r768878 - in /commons/sandbox/runtime/trunk/src/main:
java/org/apache/commons/runtime/Memory.java native/shared/memory.c
Author: mturk
Date: Mon Apr 27 07:12:22 2009
New Revision: 768878
URL: http://svn.apache.org/viewvc?rev=768878&view=rev
Log:
Check for einval in Java
Modified:
commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java
commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java?rev=768878&r1=768877&r2=768878&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Memory.java Mon Apr 27 07:12:22 2009
@@ -262,6 +262,9 @@
throws IndexOutOfBoundsException, IllegalArgumentException,
NullPointerException;
+ private static native byte[] array0(Pointer ptr, long offset, int length)
+ throws IndexOutOfBoundsException, IllegalArgumentException,
+ NullPointerException;
/**
* Return the {@code ptr} memory area from {@code src} to {@code byte} array.
*
@@ -277,8 +280,11 @@
* access of data outside allocated memory bounds.
* @throws NullPointerException if {@code ptr} is {@code null}.
*/
- public static native byte[] array(Pointer ptr, long offset, int length)
+ public static byte[] array(Pointer ptr, long offset, int length)
throws IndexOutOfBoundsException, IllegalArgumentException,
- NullPointerException;
+ NullPointerException
+ {
+ return array0(ptr, offset, length);
+ }
}
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/memory.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/memory.c?rev=768878&r1=768877&r2=768878&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/memory.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/memory.c Mon Apr 27 07:12:22 2009
@@ -422,6 +422,7 @@
size_t cs = (size_t)size;
char *d = (char *)ACR_PointerGet(_E, dst, &dl);
char *s = (char *)ACR_PointerGet(_E, src, &sl);
+
if (!d || !s) {
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
return;
@@ -450,6 +451,7 @@
size_t dn = (size_t)doff;
size_t cs = (size_t)size;
char *d = (char *)ACR_PointerGet(_E, dst, &dl);
+
if (!d) {
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
return;
@@ -473,6 +475,7 @@
size_t dn = (size_t)doff;
size_t cs = (size_t)size;
char *d = (char *)ACR_PointerGet(_E, dst, &dl);
+
if (!d) {
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
return;
@@ -489,22 +492,19 @@
memset(d + dn, c, cs);
}
-ACR_JNI_EXPORT_DECLARE(jbyteArray, Memory, array)(ACR_JNISTDARGS, jobject ptr,
- jlong poff, jint size)
+ACR_JNI_EXPORT_DECLARE(jbyteArray, Memory, array0)(ACR_JNISTDARGS, jobject ptr,
+ jlong poff, jint size)
{
jbyteArray ba;
size_t pl;
size_t dn = (size_t)poff;
size_t cs = (size_t)size;
char *p = (char *)ACR_PointerGet(_E, ptr, &pl);
+
if (!p) {
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ENULL, 0);
return NULL;
}
- if (poff < 0L || size < 1) {
- ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINVAL, 0);
- return NULL;
- }
if ((poff + cs) > pl) {
ACR_ThrowException(_E, THROW_NMARK, ACR_EX_EINDEX, 0);
return NULL;
@@ -515,3 +515,4 @@
}
return ba;
}
+