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]

Incorrect array checks in jni.cc


Hi!

This time it should be the real fix :-)

(Reason: copy complete array --> start = 0, len = array->length.
 We can copy up to array->length elements, the first is the 0.th,
 the last one has index array->length-1)

This version works with my prog, the old one throws an exception.
(o.k. that's no evidence ;-))

I hope, that this time i provided a correct patch format.


Changelog:

2001-05-03  Martin Kahlert  <martin.kahlert@infineon.com>

	* jni.cc (_Jv_JNI_GetPrimitiveArrayRegion): Fixed bounds
	checking.
	(_Jv_JNI_SetPrimitiveArrayRegion): Likewise.


The patch:

*** jni.cc.old	Thu May  3 14:56:41 2001
--- jni.cc	Thu May  3 14:56:58 2001
***************
*** 1366,1372 ****
  {
    // The cast to unsigned lets us save a comparison.
    if (start < 0 || len < 0
!       || (unsigned long) (start + len) >= (unsigned long) array->length)
      {
        try
  	{
--- 1366,1372 ----
  {
    // The cast to unsigned lets us save a comparison.
    if (start < 0 || len < 0
!       || (unsigned long) (start + len) > (unsigned long) array->length)
      {
        try
  	{
***************
*** 1393,1399 ****
  {
    // The cast to unsigned lets us save a comparison.
    if (start < 0 || len < 0
!       || (unsigned long) (start + len) >= (unsigned long) array->length)
      {
        try
  	{
--- 1393,1399 ----
  {
    // The cast to unsigned lets us save a comparison.
    if (start < 0 || len < 0
!       || (unsigned long) (start + len) > (unsigned long) array->length)
      {
        try
  	{

-- 
The early bird gets the worm. If you want something else for       
breakfast, get up later.


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